[PATCH v4 0/4] KVM: s390: Fix minor bugs in STFLE shadowing

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

 



v3 -> v4:
 * pick up tags (thanks {David, Janosch, Heiko})
 * changes to commit messages
 * flip lines and add comment (Janosch)

v2 -> v3:
 * pick up tags (thanks Claudio)
 * reverse Christmas tree

v1 -> v2:
 * pick up tags (thanks {Claudio, David})
 * drop Fixes tag on cleanup patch, change message (thanks David)
 * drop Fixes tag on second patch since the length of the facility list
   copied wasn't initially specified and only clarified in later
   revisions
 * use READ/WRITE_ONCE (thanks {David, Heiko})

Improve the STFLE vsie implementation.
Firstly, fix a bug concerning the identification if the guest is
intending to use interpretive execution for STFLE for its guest.
Secondly, decrease the amount of guest memory accessed to the
minimum.
Also do some (optional) cleanups.

Nina Schoetterl-Glausch (4):
  KVM: s390: vsie: Fix STFLE interpretive execution identification
  KVM: s390: vsie: Fix length of facility list shadowed
  KVM: s390: cpu model: Use proper define for facility mask size
  KVM: s390: Minor refactor of base/ext facility lists

 arch/s390/include/asm/facility.h |  6 +++++
 arch/s390/include/asm/kvm_host.h |  2 +-
 arch/s390/kernel/Makefile        |  2 +-
 arch/s390/kernel/facility.c      | 21 +++++++++++++++
 arch/s390/kvm/kvm-s390.c         | 44 ++++++++++++++------------------
 arch/s390/kvm/vsie.c             | 19 ++++++++++++--
 6 files changed, 65 insertions(+), 29 deletions(-)
 create mode 100644 arch/s390/kernel/facility.c

Range-diff against v3:
1:  de77a2c36786 ! 1:  69599bb38487 KVM: s390: vsie: Fix STFLE interpretive execution identification
    @@ arch/s390/kvm/vsie.c: static void retry_vsie_icpt(struct vsie_page *vsie_page)
     +	__u32 fac = READ_ONCE(vsie_page->scb_o->fac);
      
      	if (fac && test_kvm_facility(vcpu->kvm, 7)) {
    -+		fac = fac & 0x7ffffff8U;
      		retry_vsie_icpt(vsie_page);
    ++		/*
    ++		 * The facility list origin (FLO) is in bits 1 - 28 of the FLD
    ++		 * so we need to mask here before reading.
    ++		 */
    ++		fac = fac & 0x7ffffff8U;
      		if (read_guest_real(vcpu, fac, &vsie_page->fac,
      				    sizeof(vsie_page->fac)))
    + 			return set_validity_icpt(scb_s, 0x1090U);
2:  e4b44c4d2400 ! 2:  cba3c32a8db7 KVM: s390: vsie: Fix length of facility list shadowed
    @@ Commit message
     
         The length of the facility list accessed when interpretively executing
         STFLE is the same as the hosts facility list (in case of format-0)
    -    When shadowing, copy only those bytes.
    -    The memory following the facility list need not be accessible, in which
    -    case we'd wrongly inject a validity intercept.
    +    The memory following the facility list doesn't need to be accessible.
    +    The current VSIE implementation accesses a fixed length that exceeds the
    +    guest/host facility list length and can therefore wrongly inject a
    +    validity intercept.
    +    Instead, find out the host facility list length by running STFLE and
    +    copy only as much as necessary when shadowing.
     
         Acked-by: David Hildenbrand <david@xxxxxxxxxx>
         Reviewed-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
    +    Acked-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
         Signed-off-by: Nina Schoetterl-Glausch <nsg@xxxxxxxxxxxxx>
     
      ## arch/s390/include/asm/facility.h ##
    @@ arch/s390/include/asm/facility.h: static inline void stfle(u64 *stfle_fac_list,
      #endif /* __ASM_FACILITY_H */
     
      ## arch/s390/kernel/Makefile ##
    -@@ arch/s390/kernel/Makefile: obj-y	+= sysinfo.o lgr.o os_info.o
    +@@ arch/s390/kernel/Makefile: obj-y	+= sysinfo.o lgr.o os_info.o ctlreg.o
      obj-y	+= runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
      obj-y	+= entry.o reipl.o kdebugfs.o alternative.o
      obj-y	+= nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
    @@ arch/s390/kvm/vsie.c: static int handle_stfle(struct kvm_vcpu *vcpu, struct vsie
     +	 * -> format-0 flcb
     +	 */
      	if (fac && test_kvm_facility(vcpu->kvm, 7)) {
    - 		fac = fac & 0x7ffffff8U;
      		retry_vsie_icpt(vsie_page);
    + 		/*
    +@@ arch/s390/kvm/vsie.c: static int handle_stfle(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
    + 		 * so we need to mask here before reading.
    + 		 */
    + 		fac = fac & 0x7ffffff8U;
     +		/*
     +		 * format-0 -> size of nested guest's facility list == guest's size
     +		 * guest's size == host's size, since STFLE is interpretatively executed
3:  8b02ac33defb ! 3:  4b52e432d736 KVM: s390: cpu model: Use proper define for facility mask size
    @@ Commit message
         Note that both values are the same, there is no functional change.
     
         Reviewed-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
    +    Reviewed-by: David Hildenbrand <david@xxxxxxxxxx>
    +    Reviewed-by: Janosch Frank <frankja@xxxxxxxxxxxxx>
         Signed-off-by: Nina Schoetterl-Glausch <nsg@xxxxxxxxxxxxx>
     
      ## arch/s390/include/asm/kvm_host.h ##
4:  a592be823576 = 4:  9e551ba53b14 KVM: s390: Minor refactor of base/ext facility lists
-- 
2.40.1





[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