public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@intel.com
Cc: hpa@zytor.com, seanjc@google.com, elena.reshetova@intel.com,
	rick.p.edgecombe@intel.com, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCHv2 1/4] x86/tdx: Introduce tdg_vm_wr()
Date: Tue, 26 Mar 2024 07:56:04 -0700	[thread overview]
Message-ID: <55b3f9e3-8bed-4f37-8c1d-cde5e332f1ba@linux.intel.com> (raw)
In-Reply-To: <20240325104607.2653307-2-kirill.shutemov@linux.intel.com>


On 3/25/24 3:46 AM, 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.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> ---

Looks good to me.

Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>

>  arch/x86/coco/tdx/tdx.c | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
>
> 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

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer


  parent reply	other threads:[~2024-03-26 14:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 10:46 [PATCHv2 0/4] x86/tdx: Adjust TD settings on boot Kirill A. Shutemov
2024-03-25 10:46 ` [PATCHv2 1/4] x86/tdx: Introduce tdg_vm_wr() Kirill A. Shutemov
2024-03-26 10:45   ` Huang, Kai
2024-03-26 14:56   ` Kuppuswamy Sathyanarayanan [this message]
2024-04-24 17:53   ` Dave Hansen
2024-03-25 10:46 ` [PATCHv2 2/4] x86/tdx: Rename tdx_parse_tdinfo() to tdx_setup() Kirill A. Shutemov
2024-03-26 10:45   ` Huang, Kai
2024-03-25 10:46 ` [PATCHv2 3/4] x86/tdx: Handle PENDING_EPT_VIOLATION_V2 Kirill A. Shutemov
2024-04-24 18:29   ` Dave Hansen
2024-03-25 10:46 ` [PATCHv2 4/4] x86/tdx: Enable ENUM_TOPOLOGY Kirill A. Shutemov
2024-03-26 10:59   ` Huang, Kai
2024-03-26 12:21     ` kirill.shutemov
2024-04-24 22:20   ` Dave Hansen
2024-04-27 16:53     ` Kirill A. Shutemov
2024-04-10 14:37 ` [PATCHv2 0/4] x86/tdx: Adjust TD settings on boot Kirill A. Shutemov
2024-04-10 14:41   ` Edgecombe, Rick P
2024-04-12 15:01     ` kirill.shutemov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55b3f9e3-8bed-4f37-8c1d-cde5e332f1ba@linux.intel.com \
    --to=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=elena.reshetova@intel.com \
    --cc=hpa@zytor.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox