Re: [PATCH v10 10/16] x86/virt/tdx: Allocate and set up PAMTs for TDMRs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
> > +}
> > +





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux