[PATCH kernel 3/3] powerpc/pseries/iommu: Do not use H_PUT_TCE_INDIRECT in secure VM

Michael Ellerman mpe at ellerman.id.au
Fri Dec 13 21:20:10 AEDT 2019


Alexey Kardashevskiy <aik at ozlabs.ru> writes:

> H_PUT_TCE_INDIRECT uses a 4K page with TCEs to allow handling up to 512
> TCEs per hypercall. While it is a decent optimization, we rather share
> less of secure VM memory so let's avoid sharing.
>
> This only allows H_PUT_TCE_INDIRECT for normal (not secure) VMs.
>
> This keeps using H_STUFF_TCE as it does not require sharing.
>
> Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
> ---
>
> Possible alternatives are:
>
> 1. define FW_FEATURE_STUFFTCE (to allow H_STUFF_TCE) in addition to
> FW_FEATURE_MULTITCE (make it only enable H_PUT_TCE_INDIRECT) and enable
> only FW_FEATURE_STUFFTCE for SVM; pro = no SVM mention in iommu.c,
> con = a FW feature bit with very limited use

Yes let's do that please.

Actually let's rename FW_FEATURE_MULTITCE to FW_FEATURE_PUT_TCE_IND (?)
to make it clear that's what it controls now.

You should just be able to add two entries to hypertas_fw_features_table
that both look for "hcall-multi-tce". And then the SVM code disables the
PUT_TCE_IND feature at some point.

cheers

>
> 2. disable FW_FEATURE_MULTITCE and loose H_STUFF_TCE which adds a delay
> in booting process
> ---
>  arch/powerpc/platforms/pseries/iommu.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> index f6e9b87c82fc..2334a67c7614 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -192,7 +192,8 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
>  	int ret = 0;
>  	unsigned long flags;
>  
> -	if ((npages == 1) || !firmware_has_feature(FW_FEATURE_MULTITCE)) {
> +	if ((npages == 1) || !firmware_has_feature(FW_FEATURE_MULTITCE) ||
> +			is_secure_guest()) {
>  		return tce_build_pSeriesLP(tbl->it_index, tcenum,
>  					   tbl->it_page_shift, npages, uaddr,
>  		                           direction, attrs);
> @@ -402,7 +403,8 @@ static int tce_setrange_multi_pSeriesLP(unsigned long start_pfn,
>  	u64 rc = 0;
>  	long l, limit;
>  
> -	if (!firmware_has_feature(FW_FEATURE_MULTITCE)) {
> +	if (!firmware_has_feature(FW_FEATURE_MULTITCE) ||
> +			is_secure_guest()) {
>  		unsigned long tceshift = be32_to_cpu(maprange->tce_shift);
>  		unsigned long dmastart = (start_pfn << PAGE_SHIFT) +
>  				be64_to_cpu(maprange->dma_base);
> -- 
> 2.17.1


More information about the Linuxppc-dev mailing list