Re: [kvm-unit-tests PATCH v3 1/7] lib: s390x: uv: Introduce UV validity function

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

 



Quoting Janosch Frank (2023-04-21 13:36:41)
> PV related validities are in the 0x20** range but the last byte might
> be implementation specific, so everytime we check for a UV validity we
> need to mask the last byte.
> 
> Let's add a function that checks for a UV validity and returns a
> boolean.
> 
> Signed-off-by: Janosch Frank <frankja@xxxxxxxxxxxxx>
> Reviewed-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
> Reviewed-by: Nico Boehr <nrb@xxxxxxxxxxxxx>
> ---
>  lib/s390x/uv.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/lib/s390x/uv.h b/lib/s390x/uv.h
> index 5fe29bda..78b979b7 100644
> --- a/lib/s390x/uv.h
> +++ b/lib/s390x/uv.h
> @@ -35,4 +35,11 @@ static inline void uv_setup_asces(void)
>         lctlg(13, asce);
>  }
>  
> +static inline bool uv_validity_check(struct vm *vm)
> +{
> +       uint16_t vir = sie_get_validity(vm);
> +
> +       return vm->sblk->icptcode == ICPT_VALIDITY && (vir & 0xff00) == 0x2000;
> +}
> +

I noticed a small issue with this. If no intercept occurs, we sie_get_validity()
will be called which will assert() when there's none.

Please consider the following fixup (broken whitespace ahead):

 static inline bool uv_validity_check(struct vm *vm)
 {
-       uint16_t vir = sie_get_validity(vm);
+       uint16_t vir;

-       return vm->sblk->icptcode == ICPT_VALIDITY && (vir & 0xff00) == 0x2000;
+       /* must not use sie_get_validity() when there's no validity */
+       if (vm->sblk->icptcode != ICPT_VALIDITY)
+               return false;
+       vir = sie_get_validity(vm);
+
+       return (vir & 0xff00) == 0x2000;
 }





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux