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] [day] [month] [year] [list]
Message-ID: <2e0edb645393e2c75d4133b67706d2902fd51f3c.camel@intel.com>
Date: Wed, 1 Oct 2025 20:49:49 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>,
	"binbin.wu@...ux.intel.com" <binbin.wu@...ux.intel.com>
CC: "kvm@...r.kernel.org" <kvm@...r.kernel.org>, "linux-coco@...ts.linux.dev"
	<linux-coco@...ts.linux.dev>, "Zhao, Yan Y" <yan.y.zhao@...el.com>,
	"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"seanjc@...gle.com" <seanjc@...gle.com>, "mingo@...hat.com"
	<mingo@...hat.com>, "kas@...nel.org" <kas@...nel.org>, "tglx@...utronix.de"
	<tglx@...utronix.de>, "Yamahata, Isaku" <isaku.yamahata@...el.com>,
	"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
	"pbonzini@...hat.com" <pbonzini@...hat.com>, "Annapurve, Vishal"
	<vannapurve@...gle.com>, "Gao, Chao" <chao.gao@...el.com>, "bp@...en8.de"
	<bp@...en8.de>, "x86@...nel.org" <x86@...nel.org>
Subject: Re: [PATCH v3 06/16] x86/virt/tdx: Improve PAMT refcounters
 allocation for sparse memory

On Wed, 2025-10-01 at 19:00 +0000, Edgecombe, Rick P wrote:
> I guess we are really doing two separate calculations. First calculate the range
> of refcounts we need, and then calculate the range of vmalloc space we need. How
> about this, is it clearer to you? It is very specific about what/why we actually
> are doing, but at the expense of minimizing operations. In this slow path, I
> think clarity is the priority.
> 
> static int alloc_pamt_refcount(unsigned long start_pfn, unsigned long end_pfn)
> {
> 	unsigned long refcount_first, refcount_last;
> 	unsigned long mapping_start, mapping_end;
> 
> 	/*
> 	 * 'start_pfn' is inclusive and 'end_pfn' is exclusive. Find the
> 	 * range of refcounts the pfn range will need.
> 	 */
> 	refcount_first = (unsigned long)tdx_find_pamt_refcount(start_pfn);
> 	refcount_last   = (unsigned long)tdx_find_pamt_refcount(end_pfn - 1);
> 
> 	/*
> 	 * Calculate the page aligned range that includes the refcounts. The
> 	 * teardown logic needs to handle potentially overlapping refcount
> 	 * mappings resulting from the alignments.
> 	 */
> 	mapping_start = round_down(refcount_first, PAGE_SIZE);
> 	mapping_end   = round_up(refcount_last + sizeof(*pamt_refcounts),
> PAGE_SIZE);
> 
> 
> 	return apply_to_page_range(&init_mm, mapping_start, mapping_end -
> mapping_start,
> 				   pamt_refcount_populate, NULL);
> }

Yeah it's better and clearer.  LGTM.  Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ