mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-05-07 03:51:34 -04:00
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm fixes from Paolo Bonzini:
"ARM:
- Correctly handle 'invariant' system registers for protected VMs
- Improved handling of VNCR data aborts, including external aborts
- Fixes for handling of FEAT_RAS for NV guests, providing a sane
fault context during SEA injection and preventing the use of
RASv1p1 fault injection hardware
- Ensure that page table destruction when a VM is destroyed gives an
opportunity to reschedule
- Large fix to KVM's infrastructure for managing guest context loaded
on the CPU, addressing issues where the output of AT emulation
doesn't get reflected to the guest
- Fix AT S12 emulation to actually perform stage-2 translation when
necessary
- Avoid attempting vLPI irqbypass when GICv4 has been explicitly
disabled for a VM
- Minor KVM + selftest fixes
RISC-V:
- Fix pte settings within kvm_riscv_gstage_ioremap()
- Fix comments in kvm_riscv_check_vcpu_requests()
- Fix stack overrun when setting vlenb via ONE_REG
x86:
- Use array_index_nospec() to sanitize the target vCPU ID when
handling PV IPIs and yields as the ID is guest-controlled.
- Drop a superfluous cpumask_empty() check when reclaiming SEV
memory, as the common case, by far, is that at least one CPU will
have entered the VM, and wbnoinvd_on_cpus_mask() will naturally
handle the rare case where the set of have_run_cpus is empty.
Selftests (not KVM):
- Rename the is_signed_type() macro in kselftest_harness.h to
is_signed_var() to fix a collision with linux/overflow.h. The
collision generates compiler warnings due to the two macros having
different meaning"
* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (29 commits)
KVM: arm64: nv: Fix ATS12 handling of single-stage translation
KVM: arm64: Remove __vcpu_{read,write}_sys_reg_{from,to}_cpu()
KVM: arm64: Fix vcpu_{read,write}_sys_reg() accessors
KVM: arm64: Simplify sysreg access on exception delivery
KVM: arm64: Check for SYSREGS_ON_CPU before accessing the 32bit state
RISC-V: KVM: fix stack overrun when loading vlenb
RISC-V: KVM: Correct kvm_riscv_check_vcpu_requests() comment
RISC-V: KVM: Fix pte settings within kvm_riscv_gstage_ioremap()
KVM: arm64: selftests: Sync ID_AA64MMFR3_EL1 in set_id_regs
KVM: arm64: Get rid of ARM64_FEATURE_MASK()
KVM: arm64: Make ID_AA64PFR1_EL1.RAS_frac writable
KVM: arm64: Make ID_AA64PFR0_EL1.RAS writable
KVM: arm64: Ignore HCR_EL2.FIEN set by L1 guest's EL2
KVM: arm64: Handle RASv1p1 registers
arm64: Add capability denoting FEAT_RASv1p1
KVM: arm64: Reschedule as needed when destroying the stage-2 page-tables
KVM: arm64: Split kvm_pgtable_stage2_destroy()
selftests: harness: Rename is_signed_type() to avoid collision with overflow.h
KVM: SEV: don't check have_run_cpus in sev_writeback_caches()
KVM: arm64: Correctly populate FAR_EL2 on nested SEA injection
...
This commit is contained in:
@@ -751,7 +751,7 @@
|
||||
for (; _metadata->trigger; _metadata->trigger = \
|
||||
__bail(_assert, _metadata))
|
||||
|
||||
#define is_signed_type(var) (!!(((__typeof__(var))(-1)) < (__typeof__(var))1))
|
||||
#define is_signed_var(var) (!!(((__typeof__(var))(-1)) < (__typeof__(var))1))
|
||||
|
||||
#define __EXPECT(_expected, _expected_str, _seen, _seen_str, _t, _assert) do { \
|
||||
/* Avoid multiple evaluation of the cases */ \
|
||||
@@ -759,7 +759,7 @@
|
||||
__typeof__(_seen) __seen = (_seen); \
|
||||
if (!(__exp _t __seen)) { \
|
||||
/* Report with actual signedness to avoid weird output. */ \
|
||||
switch (is_signed_type(__exp) * 2 + is_signed_type(__seen)) { \
|
||||
switch (is_signed_var(__exp) * 2 + is_signed_var(__seen)) { \
|
||||
case 0: { \
|
||||
uintmax_t __exp_print = (uintmax_t)__exp; \
|
||||
uintmax_t __seen_print = (uintmax_t)__seen; \
|
||||
|
||||
@@ -169,6 +169,7 @@ TEST_GEN_PROGS_arm64 += arm64/vgic_irq
|
||||
TEST_GEN_PROGS_arm64 += arm64/vgic_lpi_stress
|
||||
TEST_GEN_PROGS_arm64 += arm64/vpmu_counter_access
|
||||
TEST_GEN_PROGS_arm64 += arm64/no-vgic-v3
|
||||
TEST_GEN_PROGS_arm64 += arm64/kvm-uuid
|
||||
TEST_GEN_PROGS_arm64 += access_tracking_perf_test
|
||||
TEST_GEN_PROGS_arm64 += arch_timer
|
||||
TEST_GEN_PROGS_arm64 += coalesced_io_test
|
||||
|
||||
@@ -146,7 +146,7 @@ static bool vcpu_aarch64_only(struct kvm_vcpu *vcpu)
|
||||
|
||||
val = vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64PFR0_EL1));
|
||||
|
||||
el0 = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_EL1_EL0), val);
|
||||
el0 = FIELD_GET(ID_AA64PFR0_EL1_EL0, val);
|
||||
return el0 == ID_AA64PFR0_EL1_EL0_IMP;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,12 +116,12 @@ static void reset_debug_state(void)
|
||||
|
||||
/* Reset all bcr/bvr/wcr/wvr registers */
|
||||
dfr0 = read_sysreg(id_aa64dfr0_el1);
|
||||
brps = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_BRPs), dfr0);
|
||||
brps = FIELD_GET(ID_AA64DFR0_EL1_BRPs, dfr0);
|
||||
for (i = 0; i <= brps; i++) {
|
||||
write_dbgbcr(i, 0);
|
||||
write_dbgbvr(i, 0);
|
||||
}
|
||||
wrps = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_WRPs), dfr0);
|
||||
wrps = FIELD_GET(ID_AA64DFR0_EL1_WRPs, dfr0);
|
||||
for (i = 0; i <= wrps; i++) {
|
||||
write_dbgwcr(i, 0);
|
||||
write_dbgwvr(i, 0);
|
||||
@@ -418,7 +418,7 @@ static void guest_code_ss(int test_cnt)
|
||||
|
||||
static int debug_version(uint64_t id_aa64dfr0)
|
||||
{
|
||||
return FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_DebugVer), id_aa64dfr0);
|
||||
return FIELD_GET(ID_AA64DFR0_EL1_DebugVer, id_aa64dfr0);
|
||||
}
|
||||
|
||||
static void test_guest_debug_exceptions(uint8_t bpn, uint8_t wpn, uint8_t ctx_bpn)
|
||||
@@ -539,14 +539,14 @@ void test_guest_debug_exceptions_all(uint64_t aa64dfr0)
|
||||
int b, w, c;
|
||||
|
||||
/* Number of breakpoints */
|
||||
brp_num = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_BRPs), aa64dfr0) + 1;
|
||||
brp_num = FIELD_GET(ID_AA64DFR0_EL1_BRPs, aa64dfr0) + 1;
|
||||
__TEST_REQUIRE(brp_num >= 2, "At least two breakpoints are required");
|
||||
|
||||
/* Number of watchpoints */
|
||||
wrp_num = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_WRPs), aa64dfr0) + 1;
|
||||
wrp_num = FIELD_GET(ID_AA64DFR0_EL1_WRPs, aa64dfr0) + 1;
|
||||
|
||||
/* Number of context aware breakpoints */
|
||||
ctx_brp_num = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_CTX_CMPs), aa64dfr0) + 1;
|
||||
ctx_brp_num = FIELD_GET(ID_AA64DFR0_EL1_CTX_CMPs, aa64dfr0) + 1;
|
||||
|
||||
pr_debug("%s brp_num:%d, wrp_num:%d, ctx_brp_num:%d\n", __func__,
|
||||
brp_num, wrp_num, ctx_brp_num);
|
||||
|
||||
70
tools/testing/selftests/kvm/arm64/kvm-uuid.c
Normal file
70
tools/testing/selftests/kvm/arm64/kvm-uuid.c
Normal file
@@ -0,0 +1,70 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
// Check that nobody has tampered with KVM's UID
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/arm-smccc.h>
|
||||
#include <asm/kvm.h>
|
||||
#include <kvm_util.h>
|
||||
|
||||
#include "processor.h"
|
||||
|
||||
/*
|
||||
* Do NOT redefine these constants, or try to replace them with some
|
||||
* "common" version. They are hardcoded here to detect any potential
|
||||
* breakage happening in the rest of the kernel.
|
||||
*
|
||||
* KVM UID value: 28b46fb6-2ec5-11e9-a9ca-4b564d003a74
|
||||
*/
|
||||
#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_0 0xb66fb428U
|
||||
#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_1 0xe911c52eU
|
||||
#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_2 0x564bcaa9U
|
||||
#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3 0x743a004dU
|
||||
|
||||
static void guest_code(void)
|
||||
{
|
||||
struct arm_smccc_res res = {};
|
||||
|
||||
smccc_hvc(ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID, 0, 0, 0, 0, 0, 0, 0, &res);
|
||||
|
||||
__GUEST_ASSERT(res.a0 == ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_0 &&
|
||||
res.a1 == ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_1 &&
|
||||
res.a2 == ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_2 &&
|
||||
res.a3 == ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3,
|
||||
"Unexpected KVM-specific UID %lx %lx %lx %lx\n", res.a0, res.a1, res.a2, res.a3);
|
||||
GUEST_DONE();
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
struct kvm_vcpu *vcpu;
|
||||
struct kvm_vm *vm;
|
||||
struct ucall uc;
|
||||
bool guest_done = false;
|
||||
|
||||
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
|
||||
|
||||
while (!guest_done) {
|
||||
vcpu_run(vcpu);
|
||||
|
||||
switch (get_ucall(vcpu, &uc)) {
|
||||
case UCALL_SYNC:
|
||||
break;
|
||||
case UCALL_DONE:
|
||||
guest_done = true;
|
||||
break;
|
||||
case UCALL_ABORT:
|
||||
REPORT_GUEST_ASSERT(uc);
|
||||
break;
|
||||
case UCALL_PRINTF:
|
||||
printf("%s", uc.buffer);
|
||||
break;
|
||||
default:
|
||||
TEST_FAIL("Unexpected guest exit");
|
||||
}
|
||||
}
|
||||
|
||||
kvm_vm_free(vm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ static void guest_code(void)
|
||||
* Check that we advertise that ID_AA64PFR0_EL1.GIC == 0, having
|
||||
* hidden the feature at runtime without any other userspace action.
|
||||
*/
|
||||
__GUEST_ASSERT(FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_EL1_GIC),
|
||||
__GUEST_ASSERT(FIELD_GET(ID_AA64PFR0_EL1_GIC,
|
||||
read_sysreg(id_aa64pfr0_el1)) == 0,
|
||||
"GICv3 wrongly advertised");
|
||||
|
||||
@@ -165,7 +165,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
vm = vm_create_with_one_vcpu(&vcpu, NULL);
|
||||
pfr0 = vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64PFR0_EL1));
|
||||
__TEST_REQUIRE(FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_EL1_GIC), pfr0),
|
||||
__TEST_REQUIRE(FIELD_GET(ID_AA64PFR0_EL1_GIC, pfr0),
|
||||
"GICv3 not supported.");
|
||||
kvm_vm_free(vm);
|
||||
|
||||
|
||||
@@ -95,14 +95,14 @@ static bool guest_check_lse(void)
|
||||
uint64_t isar0 = read_sysreg(id_aa64isar0_el1);
|
||||
uint64_t atomic;
|
||||
|
||||
atomic = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_ATOMIC), isar0);
|
||||
atomic = FIELD_GET(ID_AA64ISAR0_EL1_ATOMIC, isar0);
|
||||
return atomic >= 2;
|
||||
}
|
||||
|
||||
static bool guest_check_dc_zva(void)
|
||||
{
|
||||
uint64_t dczid = read_sysreg(dczid_el0);
|
||||
uint64_t dzp = FIELD_GET(ARM64_FEATURE_MASK(DCZID_EL0_DZP), dczid);
|
||||
uint64_t dzp = FIELD_GET(DCZID_EL0_DZP, dczid);
|
||||
|
||||
return dzp == 0;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ static bool guest_set_ha(void)
|
||||
uint64_t hadbs, tcr;
|
||||
|
||||
/* Skip if HA is not supported. */
|
||||
hadbs = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64MMFR1_EL1_HAFDBS), mmfr1);
|
||||
hadbs = FIELD_GET(ID_AA64MMFR1_EL1_HAFDBS, mmfr1);
|
||||
if (hadbs == 0)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -243,6 +243,7 @@ static void guest_code(void)
|
||||
GUEST_REG_SYNC(SYS_ID_AA64MMFR0_EL1);
|
||||
GUEST_REG_SYNC(SYS_ID_AA64MMFR1_EL1);
|
||||
GUEST_REG_SYNC(SYS_ID_AA64MMFR2_EL1);
|
||||
GUEST_REG_SYNC(SYS_ID_AA64MMFR3_EL1);
|
||||
GUEST_REG_SYNC(SYS_ID_AA64ZFR0_EL1);
|
||||
GUEST_REG_SYNC(SYS_CTR_EL0);
|
||||
GUEST_REG_SYNC(SYS_MIDR_EL1);
|
||||
@@ -594,8 +595,8 @@ static void test_user_set_mte_reg(struct kvm_vcpu *vcpu)
|
||||
*/
|
||||
val = vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64PFR1_EL1));
|
||||
|
||||
mte = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTE), val);
|
||||
mte_frac = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTE_frac), val);
|
||||
mte = FIELD_GET(ID_AA64PFR1_EL1_MTE, val);
|
||||
mte_frac = FIELD_GET(ID_AA64PFR1_EL1_MTE_frac, val);
|
||||
if (mte != ID_AA64PFR1_EL1_MTE_MTE2 ||
|
||||
mte_frac != ID_AA64PFR1_EL1_MTE_frac_NI) {
|
||||
ksft_test_result_skip("MTE_ASYNC or MTE_ASYMM are supported, nothing to test\n");
|
||||
@@ -612,7 +613,7 @@ static void test_user_set_mte_reg(struct kvm_vcpu *vcpu)
|
||||
}
|
||||
|
||||
val = vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64PFR1_EL1));
|
||||
mte_frac = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTE_frac), val);
|
||||
mte_frac = FIELD_GET(ID_AA64PFR1_EL1_MTE_frac, val);
|
||||
if (mte_frac == ID_AA64PFR1_EL1_MTE_frac_NI)
|
||||
ksft_test_result_pass("ID_AA64PFR1_EL1.MTE_frac=0 accepted and still 0xF\n");
|
||||
else
|
||||
@@ -774,7 +775,7 @@ int main(void)
|
||||
|
||||
/* Check for AARCH64 only system */
|
||||
val = vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64PFR0_EL1));
|
||||
el0 = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_EL1_EL0), val);
|
||||
el0 = FIELD_GET(ID_AA64PFR0_EL1_EL0, val);
|
||||
aarch64_only = (el0 == ID_AA64PFR0_EL1_EL0_IMP);
|
||||
|
||||
ksft_print_header();
|
||||
|
||||
@@ -441,7 +441,7 @@ static void create_vpmu_vm(void *guest_code)
|
||||
|
||||
/* Make sure that PMUv3 support is indicated in the ID register */
|
||||
dfr0 = vcpu_get_reg(vpmu_vm.vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64DFR0_EL1));
|
||||
pmuver = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_PMUVer), dfr0);
|
||||
pmuver = FIELD_GET(ID_AA64DFR0_EL1_PMUVer, dfr0);
|
||||
TEST_ASSERT(pmuver != ID_AA64DFR0_EL1_PMUVer_IMP_DEF &&
|
||||
pmuver >= ID_AA64DFR0_EL1_PMUVer_IMP,
|
||||
"Unexpected PMUVER (0x%x) on the vCPU with PMUv3", pmuver);
|
||||
|
||||
@@ -573,15 +573,15 @@ void aarch64_get_supported_page_sizes(uint32_t ipa, uint32_t *ipa4k,
|
||||
err = ioctl(vcpu_fd, KVM_GET_ONE_REG, ®);
|
||||
TEST_ASSERT(err == 0, KVM_IOCTL_ERROR(KVM_GET_ONE_REG, vcpu_fd));
|
||||
|
||||
gran = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64MMFR0_EL1_TGRAN4), val);
|
||||
gran = FIELD_GET(ID_AA64MMFR0_EL1_TGRAN4, val);
|
||||
*ipa4k = max_ipa_for_page_size(ipa, gran, ID_AA64MMFR0_EL1_TGRAN4_NI,
|
||||
ID_AA64MMFR0_EL1_TGRAN4_52_BIT);
|
||||
|
||||
gran = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64MMFR0_EL1_TGRAN64), val);
|
||||
gran = FIELD_GET(ID_AA64MMFR0_EL1_TGRAN64, val);
|
||||
*ipa64k = max_ipa_for_page_size(ipa, gran, ID_AA64MMFR0_EL1_TGRAN64_NI,
|
||||
ID_AA64MMFR0_EL1_TGRAN64_IMP);
|
||||
|
||||
gran = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64MMFR0_EL1_TGRAN16), val);
|
||||
gran = FIELD_GET(ID_AA64MMFR0_EL1_TGRAN16, val);
|
||||
*ipa16k = max_ipa_for_page_size(ipa, gran, ID_AA64MMFR0_EL1_TGRAN16_NI,
|
||||
ID_AA64MMFR0_EL1_TGRAN16_52_BIT);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user