1. 11 Nov, 2021 2 commits
    • Brijesh Singh's avatar
      mm: x86: Invoke hypercall when page encryption status is changed · 064ce6c5
      Brijesh Singh authored
      Invoke a hypercall when a memory region is changed from encrypted ->
      decrypted and vice versa. Hypervisor needs to know the page encryption
      status during the guest migration.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: x86@kernel.org
      Cc: kvm@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Reviewed-by: default avatarSteve Rutherford <srutherford@google.com>
      Reviewed-by: default avatarVenu Busireddy <venu.busireddy@oracle.com>
      Signed-off-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
      Signed-off-by: default avatarAshish Kalra <ashish.kalra@amd.com>
      Reviewed-by: default avatarBorislav Petkov <bp@suse.de>
      Message-Id: <0a237d5bb08793916c7790a3e653a2cbe7485761.1629726117.git.ashish.kalra@amd.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      064ce6c5
    • Brijesh Singh's avatar
      x86/kvm: Add AMD SEV specific Hypercall3 · 08c2336d
      Brijesh Singh authored
      KVM hypercall framework relies on alternative framework to patch the
      VMCALL -> VMMCALL on AMD platform. If a hypercall is made before
      apply_alternative() is called then it defaults to VMCALL. The approach
      works fine on non SEV guest. A VMCALL would causes #UD, and hypervisor
      will be able to decode the instruction and do the right things. But
      when SEV is active, guest memory is encrypted with guest key and
      hypervisor will not be able to decode the instruction bytes.
      
      To highlight the need to provide this interface, capturing the
      flow of apply_alternatives() :
      setup_arch() call init_hypervisor_platform() which detects
      the hypervisor platform the kernel is running under and then the
      hypervisor specific initialization code can make early hypercalls.
      For example, KVM specific initialization in case of SEV will try
      to mark the "__bss_decrypted" section's encryption state via early
      page encryption status hypercalls.
      
      Now, apply_alternatives() is called much later when setup_arch()
      calls check_bugs(), so we do need some kind of an early,
      pre-alternatives hypercall interface. Other cases of pre-alternatives
      hypercalls include marking per-cpu GHCB pages as decrypted on SEV-ES
      and per-cpu apf_reason, steal_time and kvm_apic_eoi as decrypted for
      SEV generally.
      
      Add SEV specific hypercall3, it unconditionally uses VMMCALL. The hypercall
      will be used by the SEV guest to notify encrypted pages to the hypervisor.
      
      This kvm_sev_hypercall3() function is abstracted and used as follows :
      All these early hypercalls are made through early_set_memory_XX() interfaces,
      which in turn invoke pv_ops (paravirt_ops).
      
      This early_set_memory_XX() -> pv_ops.mmu.notify_page_enc_status_changed()
      is a generic interface and can easily have SEV, TDX and any other
      future platform specific abstractions added to it.
      
      Currently, pv_ops.mmu.notify_page_enc_status_changed() callback is setup to
      invoke kvm_sev_hypercall3() in case of SEV.
      
      Similarly, in case of TDX, pv_ops.mmu.notify_page_enc_status_changed()
      can be setup to a TDX specific callback.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: x86@kernel.org
      Cc: kvm@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Reviewed-by: default avatarSteve Rutherford <srutherford@google.com>
      Reviewed-by: default avatarVenu Busireddy <venu.busireddy@oracle.com>
      Signed-off-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
      Signed-off-by: default avatarAshish Kalra <ashish.kalra@amd.com>
      Message-Id: <6fd25c749205dd0b1eb492c60d41b124760cc6ae.1629726117.git.ashish.kalra@amd.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      08c2336d
  2. 02 Nov, 2021 1 commit
  3. 01 Nov, 2021 2 commits
    • Bixuan Cui's avatar
      RISC-V: KVM: fix boolreturn.cocci warnings · bbd5ba8d
      Bixuan Cui authored
      Fix boolreturn.cocci warnings:
      ./arch/riscv/kvm/mmu.c:603:9-10: WARNING: return of 0/1 in function
      'kvm_age_gfn' with return type bool
      ./arch/riscv/kvm/mmu.c:582:9-10: WARNING: return of 0/1 in function
      'kvm_set_spte_gfn' with return type bool
      ./arch/riscv/kvm/mmu.c:621:9-10: WARNING: return of 0/1 in function
      'kvm_test_age_gfn' with return type bool
      ./arch/riscv/kvm/mmu.c:568:9-10: WARNING: return of 0/1 in function
      'kvm_unmap_gfn_range' with return type bool
      Signed-off-by: default avatarBixuan Cui <cuibixuan@linux.alibaba.com>
      Signed-off-by: default avatarAnup Patel <anup.patel@wdc.com>
      bbd5ba8d
    • ran jianping's avatar
      RISC-V: KVM: remove unneeded semicolon · 7b161d9c
      ran jianping authored
       Elimate the following coccinelle check warning:
       ./arch/riscv/kvm/vcpu_sbi.c:169:2-3: Unneeded semicolon
       ./arch/riscv/kvm/vcpu_exit.c:397:2-3: Unneeded semicolon
       ./arch/riscv/kvm/vcpu_exit.c:687:2-3: Unneeded semicolon
       ./arch/riscv/kvm/vcpu_exit.c:645:2-3: Unneeded semicolon
       ./arch/riscv/kvm/vcpu.c:247:2-3: Unneeded semicolon
       ./arch/riscv/kvm/vcpu.c:284:2-3: Unneeded semicolon
       ./arch/riscv/kvm/vcpu_timer.c:123:2-3: Unneeded semicolon
       ./arch/riscv/kvm/vcpu_timer.c:170:2-3: Unneeded semicolon
      Reported-by: default avatarZeal Robot <zealci@zte.com.cn>
      Signed-off-by: default avatarran jianping <ran.jianping@zte.com.cn>
      Signed-off-by: default avatarAnup Patel <anup.patel@wdc.com>
      7b161d9c
  4. 31 Oct, 2021 4 commits
    • Paolo Bonzini's avatar
      Merge tag 'kvm-s390-next-5.16-1' of... · 9c6eb531
      Paolo Bonzini authored
      Merge tag 'kvm-s390-next-5.16-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD
      
      KVM: s390: Fixes and Features for 5.16
      
      - SIGP Fixes
      - initial preparations for lazy destroy of secure VMs
      - storage key improvements/fixes
      - Log the guest CPNC
      9c6eb531
    • Anup Patel's avatar
      RISC-V: KVM: Fix GPA passed to __kvm_riscv_hfence_gvma_xyz() functions · 7c8de080
      Anup Patel authored
      The parameter passed to HFENCE.GVMA instruction in rs1 register
      is guest physical address right shifted by 2 (i.e. divided by 4).
      
      Unfortunately, we overlooked the semantics of rs1 registers for
      HFENCE.GVMA instruction and never right shifted guest physical
      address by 2. This issue did not manifest for hypervisors till
      now because:
        1) Currently, only __kvm_riscv_hfence_gvma_all() and SBI
           HFENCE calls are used to invalidate TLB.
        2) All H-extension implementations (such as QEMU, Spike,
           Rocket Core FPGA, etc) that we tried till now were
           conservatively flushing everything upon any HFENCE.GVMA
           instruction.
      
      This patch fixes GPA passed to __kvm_riscv_hfence_gvma_vmid_gpa()
      and __kvm_riscv_hfence_gvma_gpa() functions.
      
      Fixes: fd7bb4a2 ("RISC-V: KVM: Implement VMID allocator")
      Reported-by: default avatarIan Huang <ihuang@ventanamicro.com>
      Signed-off-by: default avatarAnup Patel <anup.patel@wdc.com>
      Message-Id: <20211026170136.2147619-4-anup.patel@wdc.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      7c8de080
    • Anup Patel's avatar
      RISC-V: KVM: Factor-out FP virtualization into separate sources · 0a86512d
      Anup Patel authored
      The timer and SBI virtualization is already in separate sources.
      In future, we will have vector and AIA virtualization also added
      as separate sources.
      
      To align with above described modularity, we factor-out FP
      virtualization into separate sources.
      Signed-off-by: default avatarAnup Patel <anup.patel@wdc.com>
      Message-Id: <20211026170136.2147619-3-anup.patel@wdc.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      0a86512d
    • Paolo Bonzini's avatar
      Merge tag 'kvmarm-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD · 4e338684
      Paolo Bonzini authored
      KVM/arm64 updates for Linux 5.16
      
      - More progress on the protected VM front, now with the full
        fixed feature set as well as the limitation of some hypercalls
        after initialisation.
      
      - Cleanup of the RAZ/WI sysreg handling, which was pointlessly
        complicated
      
      - Fixes for the vgic placement in the IPA space, together with a
        bunch of selftests
      
      - More memcg accounting of the memory allocated on behalf of a guest
      
      - Timer and vgic selftests
      
      - Workarounds for the Apple M1 broken vgic implementation
      
      - KConfig cleanups
      
      - New kvmarm.mode=none option, for those who really dislike us
      4e338684
  5. 27 Oct, 2021 3 commits
  6. 25 Oct, 2021 20 commits
  7. 22 Oct, 2021 8 commits