linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Michael Roth <michael.roth@amd.com>
Cc: linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
	Kees Cook <keescook@chromium.org>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Tony Luck <tony.luck@intel.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Kuppuswamy Sathyanarayanan 
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Venu Busireddy <venu.busireddy@oracle.com>,
	Joerg Roedel <jroedel@suse.de>,
	Tianyu Lan <Tianyu.Lan@microsoft.com>,
	Brijesh Singh <brijesh.singh@amd.com>
Subject: Re: [PATCH] x86/sev: get the AP jump table address from secrets page
Date: Wed, 20 Apr 2022 20:30:51 +0200	[thread overview]
Message-ID: <YmBRW6xMhNiW7JRU@zn.tnic> (raw)
In-Reply-To: <20220420152751.145180-1-michael.roth@amd.com>

On Wed, Apr 20, 2022 at 10:27:51AM -0500, Michael Roth wrote:
> +static u64 get_secrets_page(void)
> +{
> +	u64 pa_data = boot_params.cc_blob_address;
> +	struct cc_blob_sev_info info;
> +	void *map;
> +
> +	/*
> +	 * The CC blob contains the address of the secrets page, check if the
> +	 * blob is present.
> +	 */
> +	if (!pa_data)
> +		return 0;
> +
> +	map = early_memremap(pa_data, sizeof(info));

That function can return NULL so you need to handle it.

> +	memcpy(&info, map, sizeof(info));
> +	early_memunmap(map, sizeof(info));
> +
> +	/* smoke-test the secrets page passed */
> +	if (!info.secrets_phys || info.secrets_len != PAGE_SIZE)
> +		return 0;
> +
> +	return info.secrets_phys;
> +}
> +
> +static u64 get_snp_jump_table_addr(void)
> +{
> +	struct snp_secrets_page_layout *layout;
> +	u64 pa = get_secrets_page();
> +	u64 addr;

Please don't hide the function call in the local variables declaration
but do this instead:

        struct snp_secrets_page_layout *layout;
        u64 pa, addr;

        pa = get_secrets_page();
        if (!pa)
                return 0;

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

      reply	other threads:[~2022-04-20 18:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 15:27 [PATCH] x86/sev: get the AP jump table address from secrets page Michael Roth
2022-04-20 18:30 ` Borislav Petkov [this message]

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=YmBRW6xMhNiW7JRU@zn.tnic \
    --to=bp@alien8.de \
    --cc=Tianyu.Lan@microsoft.com \
    --cc=brijesh.singh@amd.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jroedel@suse.de \
    --cc=keescook@chromium.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=ndesaulniers@google.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=tony.luck@intel.com \
    --cc=venu.busireddy@oracle.com \
    --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;
as well as URLs for NNTP newsgroup(s).