[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6ca837b8-f6eb-464c-9284-1c70f3a616a5@intel.com>
Date: Wed, 24 Apr 2024 10:53:00 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de
Cc: sathyanarayanan.kuppuswamy@...ux.intel.com, hpa@...or.com,
seanjc@...gle.com, elena.reshetova@...el.com, rick.p.edgecombe@...el.com,
x86@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCHv2 1/4] x86/tdx: Introduce tdg_vm_wr()
So, the text here should help me understand what is going on. What it
tries to tell me should not be a literal rephrasing of the contents of
the diff.
This patch literally introduces a function called tdg_vm_wr(). The
subject adds precisely zero to what I can get from reading the diff.
How about:
x86/tdx: Factor out TD metadata write tdcall
On 3/25/24 03:46, Kirill A. Shutemov wrote:
> Add a helper function to write to a TD-scope metadata field and use it
> to set NOTIFY_ENABLES.
>
> The helper function will be paired with tdg_vm_rd() and will be used to
> manipulate other metadata fields, not just NOTIFY_ENABLES.
Ideally this would at least tell me what problem this is solving:
The TDG_VM_WR seamcall is used to ask the TDX module to change
some TD-specific VM configuration. There is currently only one
user in the kernel of this seamcall. More will be added
shortly.
.. and then the solution:
Refactor to make way for more users of TDG_VM_WR who will need
to modify other TD configuration values.
> diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
> index 59776ce1c1d7..4fb36e5c4e80 100644
> --- a/arch/x86/coco/tdx/tdx.c
> +++ b/arch/x86/coco/tdx/tdx.c
> @@ -77,6 +77,20 @@ static inline void tdcall(u64 fn, struct tdx_module_args *args)
> panic("TDCALL %lld failed (Buggy TDX module!)\n", fn);
> }
>
> +static inline u64 tdg_vm_wr(u64 field, u64 value, u64 mask)
> +{
> + struct tdx_module_args args = {
> + .rdx = field,
> + .r8 = value,
> + .r9 = mask,
> + };
> +
> + tdcall(TDG_VM_WR, &args);
> +
> + /* Old value */
> + return args.r8;
> +}
> +
> /**
> * tdx_mcall_get_report0() - Wrapper to get TDREPORT0 (a.k.a. TDREPORT
> * subtype 0) using TDG.MR.REPORT TDCALL.
> @@ -902,10 +916,6 @@ static void tdx_kexec_unshare_mem(void)
>
> void __init tdx_early_init(void)
> {
> - struct tdx_module_args args = {
> - .rdx = TDCS_NOTIFY_ENABLES,
> - .r9 = -1ULL,
> - };
> u64 cc_mask;
> u32 eax, sig[3];
>
> @@ -924,7 +934,7 @@ void __init tdx_early_init(void)
> cc_set_mask(cc_mask);
>
> /* Kernel does not use NOTIFY_ENABLES and does not need random #VEs */
> - tdcall(TDG_VM_WR, &args);
> + tdg_vm_wr(TDCS_NOTIFY_ENABLES, 0, -1ULL);
>
> /*
> * All bits above GPA width are reserved and kernel treats shared bit
Powered by blists - more mailing lists