Skip to content

Commit 122333d

Browse files
Nikolay Borisovhansendc
authored andcommitted
x86/tdx: Wrap exit reason with hcall_func()
TDX reuses VMEXIT "reasons" in its guest->host hypercall ABI. This is confusing because there might not be a VMEXIT involved at *all*. These instances are supposed to document situation and reduce confusion by wrapping VMEXIT reasons with hcall_func(). The decompression code does not follow this convention. Unify the TDX decompression code with the other TDX use of VMEXIT reasons. No functional changes. Signed-off-by: Nikolay Borisov <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Link: https://lore.kernel.org/all/20230505120332.1429957-1-nik.borisov%40suse.com
1 parent 44c026a commit 122333d

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

arch/x86/boot/compressed/tdx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static inline unsigned int tdx_io_in(int size, u16 port)
2020
{
2121
struct tdx_hypercall_args args = {
2222
.r10 = TDX_HYPERCALL_STANDARD,
23-
.r11 = EXIT_REASON_IO_INSTRUCTION,
23+
.r11 = hcall_func(EXIT_REASON_IO_INSTRUCTION),
2424
.r12 = size,
2525
.r13 = 0,
2626
.r14 = port,
@@ -36,7 +36,7 @@ static inline void tdx_io_out(int size, u16 port, u32 value)
3636
{
3737
struct tdx_hypercall_args args = {
3838
.r10 = TDX_HYPERCALL_STANDARD,
39-
.r11 = EXIT_REASON_IO_INSTRUCTION,
39+
.r11 = hcall_func(EXIT_REASON_IO_INSTRUCTION),
4040
.r12 = size,
4141
.r13 = 1,
4242
.r14 = port,

arch/x86/coco/tdx/tdx.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,6 @@ noinstr void __tdx_hypercall_failed(void)
7676
panic("TDVMCALL failed. TDX module bug?");
7777
}
7878

79-
/*
80-
* The TDG.VP.VMCALL-Instruction-execution sub-functions are defined
81-
* independently from but are currently matched 1:1 with VMX EXIT_REASONs.
82-
* Reusing the KVM EXIT_REASON macros makes it easier to connect the host and
83-
* guest sides of these calls.
84-
*/
85-
static __always_inline u64 hcall_func(u64 exit_reason)
86-
{
87-
return exit_reason;
88-
}
89-
9079
#ifdef CONFIG_KVM_GUEST
9180
long tdx_kvm_hypercall(unsigned int nr, unsigned long p1, unsigned long p2,
9281
unsigned long p3, unsigned long p4)

arch/x86/include/asm/shared/tdx.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,16 @@ u64 __tdx_hypercall_ret(struct tdx_hypercall_args *args);
4040
/* Called from __tdx_hypercall() for unrecoverable failure */
4141
void __tdx_hypercall_failed(void);
4242

43+
/*
44+
* The TDG.VP.VMCALL-Instruction-execution sub-functions are defined
45+
* independently from but are currently matched 1:1 with VMX EXIT_REASONs.
46+
* Reusing the KVM EXIT_REASON macros makes it easier to connect the host and
47+
* guest sides of these calls.
48+
*/
49+
static __always_inline u64 hcall_func(u64 exit_reason)
50+
{
51+
return exit_reason;
52+
}
53+
4354
#endif /* !__ASSEMBLY__ */
4455
#endif /* _ASM_X86_SHARED_TDX_H */

0 commit comments

Comments
 (0)