[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ce375c4a84bb0aafae73df8ddbcd1dc7024cee79.camel@intel.com>
Date: Tue, 21 Mar 2023 08:05:52 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"Dong, Eddie" <eddie.dong@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC: "Hansen, Dave" <dave.hansen@...el.com>,
"Luck, Tony" <tony.luck@...el.com>,
"david@...hat.com" <david@...hat.com>,
"ak@...ux.intel.com" <ak@...ux.intel.com>,
"Wysocki, Rafael J" <rafael.j.wysocki@...el.com>,
"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
"Christopherson,, Sean" <seanjc@...gle.com>,
"Chatre, Reinette" <reinette.chatre@...el.com>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"Yamahata, Isaku" <isaku.yamahata@...el.com>,
"bagasdotme@...il.com" <bagasdotme@...il.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"peterz@...radead.org" <peterz@...radead.org>,
"Shahar, Sagi" <sagis@...gle.com>,
"imammedo@...hat.com" <imammedo@...hat.com>,
"Gao, Chao" <chao.gao@...el.com>,
"Brown, Len" <len.brown@...el.com>,
"sathyanarayanan.kuppuswamy@...ux.intel.com"
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"Huang, Ying" <ying.huang@...el.com>,
"Williams, Dan J" <dan.j.williams@...el.com>
Subject: Re: [PATCH v10 10/16] x86/virt/tdx: Allocate and set up PAMTs for
TDMRs
On Tue, 2023-03-21 at 07:44 +0000, Dong, Eddie 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, int pgsz,
> > + u16 pamt_entry_size)
> > +{
> > + unsigned long pamt_sz, nr_pamt_entries;
> > +
> > + switch (pgsz) {
> > + case TDX_PS_4K:
> > + nr_pamt_entries = tdmr->size >> PAGE_SHIFT;
> > + break;
> > + case TDX_PS_2M:
> > + nr_pamt_entries = tdmr->size >> PMD_SHIFT;
> > + break;
> > + case TDX_PS_1G:
> > + nr_pamt_entries = tdmr->size >> PUD_SHIFT;
> > + break;
> > + default:
> > + WARN_ON_ONCE(1);
> > + return 0;
> > + }
> > +
> > + pamt_sz = nr_pamt_entries * pamt_entry_size;
> > + /* TDX requires PAMT size must be 4K aligned */
> > + pamt_sz = ALIGN(pamt_sz, PAGE_SIZE);
>
> Should we ALIGN_UP for safe ?
Hi Eddie,
ALIGN() already does align up.
>
> > +
> > + return pamt_sz;
> > +}
> > +
Powered by blists - more mailing lists