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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6c545c841afcd23e1b3a4fcb47573ee3a178d6e1.camel@intel.com>
Date: Tue, 16 Sep 2025 00:03:26 +0000
From: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
To: "kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
	"pbonzini@...hat.com" <pbonzini@...hat.com>, "seanjc@...gle.com"
	<seanjc@...gle.com>, "dave.hansen@...ux.intel.com"
	<dave.hansen@...ux.intel.com>
CC: "Gao, Chao" <chao.gao@...el.com>, "bp@...en8.de" <bp@...en8.de>, "Huang,
 Kai" <kai.huang@...el.com>, "x86@...nel.org" <x86@...nel.org>,
	"mingo@...hat.com" <mingo@...hat.com>, "Zhao, Yan Y" <yan.y.zhao@...el.com>,
	"tglx@...utronix.de" <tglx@...utronix.de>, "kvm@...r.kernel.org"
	<kvm@...r.kernel.org>, "linux-coco@...ts.linux.dev"
	<linux-coco@...ts.linux.dev>, "Yamahata, Isaku" <isaku.yamahata@...el.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCHv2 04/12] x86/virt/tdx: Add tdx_alloc/free_page() helpers

On Mon, 2025-06-09 at 22:13 +0300, Kirill A. Shutemov wrote:
> +
> +static int tdx_pamt_add(atomic_t *pamt_refcount, unsigned long hpa,
> +			struct list_head *pamt_pages)
> +{
> +	u64 err;
> +
> +	guard(spinlock)(&pamt_lock);
> +
> +	hpa = ALIGN_DOWN(hpa, PMD_SIZE);
> +
> +	/* Lost race to other tdx_pamt_add() */
> +	if (atomic_read(pamt_refcount) != 0) {
> +		atomic_inc(pamt_refcount);
> +		return 1;
> +	}
> +
> +	err = tdh_phymem_pamt_add(hpa | TDX_PS_2M, pamt_pages);
> +
> +	/*
> +	 * tdx_hpa_range_not_free() is true if current task won race
> +	 * against tdx_pamt_put().
> +	 */
> +	if (err && !tdx_hpa_range_not_free(err)) {
> +		pr_err("TDH_PHYMEM_PAMT_ADD failed: %#llx\n", err);
> +		return -EIO;
> +	}
> +
> +	atomic_set(pamt_refcount, 1);
> +
> +	if (tdx_hpa_range_not_free(err))
> +		return 1;

Hey Kirill,

I couldn't figure out how this tdx_hpa_range_not_free() check helps. We are
already inside the lock also taken by any operation that might affect PAMT
state. Can you explain more about this? Otherwise I'm going to drop it for
inability to explain.

Rick

> +
> +	return 0;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ