[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1a33401208b27c8a0fcd45c061e49c66a14ea6f5.camel@intel.com>
Date: Wed, 17 Aug 2022 23:43:19 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "Shahar, Sagi" <sagis@...gle.com>
CC: "Brown, Len" <len.brown@...el.com>,
"Hansen, Dave" <dave.hansen@...el.com>,
"Christopherson,, Sean" <seanjc@...gle.com>,
"ak@...ux.intel.com" <ak@...ux.intel.com>,
"peterz@...radead.org" <peterz@...radead.org>,
"Chatre, Reinette" <reinette.chatre@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Williams, Dan J" <dan.j.williams@...el.com>,
"Luck, Tony" <tony.luck@...el.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"Wysocki, Rafael J" <rafael.j.wysocki@...el.com>,
"sathyanarayanan.kuppuswamy@...ux.intel.com"
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
"Yamahata, Isaku" <isaku.yamahata@...el.com>
Subject: Re: [PATCH v5 15/22] x86/virt/tdx: Allocate and set up PAMTs for
TDMRs
On Wed, 2022-08-17 at 15:46 -0700, Sagi Shahar wrote:
> > +/*
> > + * Calculate PAMT size given a TDMR and a page size. The returned
> > + * PAMT size is always aligned up to 4K page boundary.
> > + */
> > +static unsigned long tdmr_get_pamt_sz(struct tdmr_info *tdmr,
> > + enum tdx_page_sz pgsz)
> > +{
> > + unsigned long pamt_sz;
> > + int pamt_entry_nr;
> ^
> This should be an 'unsigned long'. Otherwise you get an integer
> overflow for large memory machines.
Agreed. Thanks.
>
> > +
> > + switch (pgsz) {
> > + case TDX_PG_4K:
> > + pamt_entry_nr = tdmr->size >> PAGE_SHIFT;
> > + break;
> > + case TDX_PG_2M:
> > + pamt_entry_nr = tdmr->size >> PMD_SHIFT;
> > + break;
> > + case TDX_PG_1G:
> > + pamt_entry_nr = tdmr->size >> PUD_SHIFT;
> > + break;
> > + default:
> > + WARN_ON_ONCE(1);
> > + return 0;
> > + }
> > +
> > + pamt_sz = pamt_entry_nr * tdx_sysinfo.pamt_entry_size;
> > + /* TDX requires PAMT size must be 4K aligned */
> > + pamt_sz = ALIGN(pamt_sz, PAGE_SIZE);
> > +
> > + return pamt_sz;
> > +}
> > +
Powered by blists - more mailing lists