Re: [PATCH v6 11/42] x86/sev: Check the vmpl level

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 08, 2021 at 01:04:22PM -0500, Brijesh Singh wrote:
> +static bool is_vmpl0(void)
> +{
> +	u64 attrs, va;

That local variable va is not needed.

> +	int err;
> +
> +	/*
> +	 * There is no straightforward way to query the current VMPL level. The
> +	 * simplest method is to use the RMPADJUST instruction to change a page
> +	 * permission to a VMPL level-1, and if the guest kernel is launched at
> +	 * a level <= 1, then RMPADJUST instruction will return an error.
> +	 */
> +	attrs = 1;
> +
> +	/*
> +	 * Any page aligned virtual address is sufficent to test the VMPL level.

"page-aligned" ... 				"sufficient"

> +	 * The boot_ghcb_page is page aligned memory, so lets use for the test.
> +	 */
> +	va = (u64)&boot_ghcb_page;
> +
> +	/* Instruction mnemonic supported in binutils versions v2.36 and later */
> +	asm volatile (".byte 0xf3,0x0f,0x01,0xfe\n\t"
> +		      : "=a" (err)
> +		      : "a" (va), "c" (RMP_PG_SIZE_4K), "d" (attrs)
> +		      : "memory", "cc");

You're adding a separate rmpadjust() primitive function in patch 24.
In order to avoid duplication, define that primitive first, just like
you've done for PVALIDATE in the previous patch and use said primitive
at both call sites.

-- 
Regards/Gruss,
    Boris.

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



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux