Skip to content

Commit d04f7de

Browse files
committed
Merge tag 'x86_sev_for_v5.14_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 SEV updates from Borislav Petkov: - Differentiate the type of exception the #VC handler raises depending on code executed in the guest and handle the case where failure to get the RIP would result in a #GP, as it should, instead of in a #PF - Disable interrupts while the per-CPU GHCB is held - Split the #VC handler depending on where the #VC exception has happened and therefore provide for precise context tracking like the rest of the exception handlers deal with noinstr regions now - Add defines for the GHCB version 2 protocol so that further shared development with KVM can happen without merge conflicts - The usual small cleanups * tag 'x86_sev_for_v5.14_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/sev: Use "SEV: " prefix for messages from sev.c x86/sev: Add defines for GHCB version 2 MSR protocol requests x86/sev: Split up runtime #VC handler for correct state tracking x86/sev: Make sure IRQs are disabled while GHCB is active x86/sev: Propagate #GP if getting linear instruction address failed x86/insn: Extend error reporting from insn_fetch_from_user[_inatomic]() x86/insn-eval: Make 0 a valid RIP for insn_get_effective_ip() x86/sev: Fix error message in runtime #VC handler
2 parents 2594b71 + 8d9d46b commit d04f7de

6 files changed

Lines changed: 160 additions & 130 deletions

File tree

arch/x86/entry/entry_64.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ SYM_CODE_START(\asmsym)
506506

507507
movq %rsp, %rdi /* pt_regs pointer */
508508

509-
call \cfunc
509+
call kernel_\cfunc
510510

511511
/*
512512
* No need to switch back to the IST stack. The current stack is either
@@ -517,7 +517,7 @@ SYM_CODE_START(\asmsym)
517517

518518
/* Switch to the regular task stack */
519519
.Lfrom_usermode_switch_stack_\@:
520-
idtentry_body safe_stack_\cfunc, has_error_code=1
520+
idtentry_body user_\cfunc, has_error_code=1
521521

522522
_ASM_NOKPROBE(\asmsym)
523523
SYM_CODE_END(\asmsym)

arch/x86/include/asm/idtentry.h

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ static __always_inline void __##func(struct pt_regs *regs)
312312
*/
313313
#define DECLARE_IDTENTRY_VC(vector, func) \
314314
DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func); \
315-
__visible noinstr void ist_##func(struct pt_regs *regs, unsigned long error_code); \
316-
__visible noinstr void safe_stack_##func(struct pt_regs *regs, unsigned long error_code)
315+
__visible noinstr void kernel_##func(struct pt_regs *regs, unsigned long error_code); \
316+
__visible noinstr void user_##func(struct pt_regs *regs, unsigned long error_code)
317317

318318
/**
319319
* DEFINE_IDTENTRY_IST - Emit code for IST entry points
@@ -355,33 +355,24 @@ static __always_inline void __##func(struct pt_regs *regs)
355355
DEFINE_IDTENTRY_RAW_ERRORCODE(func)
356356

357357
/**
358-
* DEFINE_IDTENTRY_VC_SAFE_STACK - Emit code for VMM communication handler
359-
which runs on a safe stack.
358+
* DEFINE_IDTENTRY_VC_KERNEL - Emit code for VMM communication handler
359+
when raised from kernel mode
360360
* @func: Function name of the entry point
361361
*
362362
* Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
363363
*/
364-
#define DEFINE_IDTENTRY_VC_SAFE_STACK(func) \
365-
DEFINE_IDTENTRY_RAW_ERRORCODE(safe_stack_##func)
364+
#define DEFINE_IDTENTRY_VC_KERNEL(func) \
365+
DEFINE_IDTENTRY_RAW_ERRORCODE(kernel_##func)
366366

367367
/**
368-
* DEFINE_IDTENTRY_VC_IST - Emit code for VMM communication handler
369-
which runs on the VC fall-back stack
368+
* DEFINE_IDTENTRY_VC_USER - Emit code for VMM communication handler
369+
when raised from user mode
370370
* @func: Function name of the entry point
371371
*
372372
* Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
373373
*/
374-
#define DEFINE_IDTENTRY_VC_IST(func) \
375-
DEFINE_IDTENTRY_RAW_ERRORCODE(ist_##func)
376-
377-
/**
378-
* DEFINE_IDTENTRY_VC - Emit code for VMM communication handler
379-
* @func: Function name of the entry point
380-
*
381-
* Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
382-
*/
383-
#define DEFINE_IDTENTRY_VC(func) \
384-
DEFINE_IDTENTRY_RAW_ERRORCODE(func)
374+
#define DEFINE_IDTENTRY_VC_USER(func) \
375+
DEFINE_IDTENTRY_RAW_ERRORCODE(user_##func)
385376

386377
#else /* CONFIG_X86_64 */
387378

arch/x86/include/asm/sev-common.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
#define __ASM_X86_SEV_COMMON_H
1010

1111
#define GHCB_MSR_INFO_POS 0
12-
#define GHCB_MSR_INFO_MASK (BIT_ULL(12) - 1)
12+
#define GHCB_DATA_LOW 12
13+
#define GHCB_MSR_INFO_MASK (BIT_ULL(GHCB_DATA_LOW) - 1)
1314

15+
#define GHCB_DATA(v) \
16+
(((unsigned long)(v) & ~GHCB_MSR_INFO_MASK) >> GHCB_DATA_LOW)
17+
18+
/* SEV Information Request/Response */
1419
#define GHCB_MSR_SEV_INFO_RESP 0x001
1520
#define GHCB_MSR_SEV_INFO_REQ 0x002
1621
#define GHCB_MSR_VER_MAX_POS 48
@@ -28,6 +33,7 @@
2833
#define GHCB_MSR_PROTO_MAX(v) (((v) >> GHCB_MSR_VER_MAX_POS) & GHCB_MSR_VER_MAX_MASK)
2934
#define GHCB_MSR_PROTO_MIN(v) (((v) >> GHCB_MSR_VER_MIN_POS) & GHCB_MSR_VER_MIN_MASK)
3035

36+
/* CPUID Request/Response */
3137
#define GHCB_MSR_CPUID_REQ 0x004
3238
#define GHCB_MSR_CPUID_RESP 0x005
3339
#define GHCB_MSR_CPUID_FUNC_POS 32
@@ -45,6 +51,14 @@
4551
(((unsigned long)reg & GHCB_MSR_CPUID_REG_MASK) << GHCB_MSR_CPUID_REG_POS) | \
4652
(((unsigned long)fn) << GHCB_MSR_CPUID_FUNC_POS))
4753

54+
/* AP Reset Hold */
55+
#define GHCB_MSR_AP_RESET_HOLD_REQ 0x006
56+
#define GHCB_MSR_AP_RESET_HOLD_RESP 0x007
57+
58+
/* GHCB Hypervisor Feature Request/Response */
59+
#define GHCB_MSR_HV_FT_REQ 0x080
60+
#define GHCB_MSR_HV_FT_RESP 0x081
61+
4862
#define GHCB_MSR_TERM_REQ 0x100
4963
#define GHCB_MSR_TERM_REASON_SET_POS 12
5064
#define GHCB_MSR_TERM_REASON_SET_MASK 0xf

0 commit comments

Comments
 (0)