lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e257f5fa-e209-8a5b-659c-129abb72be42@intel.com>
Date:   Thu, 20 May 2021 13:56:13 -0700
From:   Dave Hansen <dave.hansen@...el.com>
To:     Sean Christopherson <seanjc@...gle.com>,
        "Kuppuswamy, Sathyanarayanan" 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Andy Lutomirski <luto@...nel.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Tony Luck <tony.luck@...el.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Kirill Shutemov <kirill.shutemov@...ux.intel.com>,
        Kuppuswamy Sathyanarayanan <knsathya@...nel.org>,
        Raj Ashok <ashok.raj@...el.com>, linux-kernel@...r.kernel.org
Subject: Re: [RFC v2 27/32] x86/tdx: Exclude Shared bit from __PHYSICAL_MASK

On 5/20/21 1:16 PM, Sean Christopherson wrote:
> On Thu, May 20, 2021, Kuppuswamy, Sathyanarayanan wrote:
>> So what is your proposal? "tdx_guest_" / "tdx_host_" ?
>   1. Abstract things where appropriate, e.g. I'm guessing there is a clever way
>      to deal with the shared vs. private inversion and avoid tdg_shared_mask
>      altogether.

One example here would be to keep a structure like:

struct protected_mem_config
{
	unsigned long p_set_bits;
	unsigned long p_clear_bits;
}

Where 'p_set_bits' are the bits that need to be set to establish memory
protection and 'p_clear_bits' are the bits that need to be cleared.
physical_mask would clear both of them:

	physical_mask &= ~(pmc.p_set_bits & pmc.p_set_bits);

Then, in a place like __set_memory_enc_dec(), you would query whether
memory protection was in place or not:
	
+	if (protect) {
+		cpa.mask_set = pmc.p_set_bits;
+		cpa.mask_clr = pmc.p_clear_bits;
+		map_type = TDX_MAP_PRIVATE;
+	} else {
+		cpa.mask_set = pmc.p_clear_bits;
+		cpa.mask_clr = pmc.p_set_bits;
+		map_type = TDX_MAP_SHARED;
+	}

The is_tdx_guest() if()'s would just go away.

Basically, if there's a is_tdx_guest() check in common code, it's a
place that might need an abstraction.

This, for instance:

> +	if (!ret && is_tdx_guest()) {
> +		ret = tdg_map_gpa(__pa(addr), numpages, map_type);
> +	}

could probably just be:

	if (!ret && is_protected_guest()) {
		ret = x86_vmm_protect(__pa(addr), numpages, protected);
	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ