From patchwork Wed Mar 2 20:52:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 547526 Delivered-To: patch@linaro.org Received: by 2002:ac0:f585:0:0:0:0:0 with SMTP id s5csp34737imq; Wed, 2 Mar 2022 13:05:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyiLgxChAXGbI0whr0N9yiK2/SyqnVTFvVC/79xyA4Tlc8NTkU9mHBTPBFGxeDS1LjgtK95 X-Received: by 2002:a9d:2f61:0:b0:5af:5d99:29ed with SMTP id h88-20020a9d2f61000000b005af5d9929edmr17473542otb.142.1646255140253; Wed, 02 Mar 2022 13:05:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646255140; cv=none; d=google.com; s=arc-20160816; b=DV8VdJ24fE05DAF3uEunumuLW2aBFztjFLMeGxd9nZPw6FVXi85FPI3yl2BJvsINIp 7Fy6LTJ7CTwBfcIHS7Mw24dPU4Ov1kObQVd53zA0tWTu7QQoxs/Aq3gF3azqoVNYeFD1 h74lzLAZQiATDHgCrjaivma/oRVvUTKOW7MkUNjVcIpjqTpkpR7zzCbyXhGNnNXFHuuN 0UAz9XBpa3MVKbH+J5oE44ZtxgKGanHsMm8q3jnvYfRR6nHTq1rCksORM4ccAaXGsm4A npFwpQULaWUvv8/MIQeuIp6PjnzECqMaIFzi3QbM59yQ+OMDnUUKhxGmBnVheoGUXNbN cj/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=l/7EADgfQiDC7fxjtgYtq9X1xBlDjXtx1HGr/ZG8QYc=; b=UQ7/coYrGZTbUo/38IO9W/vgSvS3E7zrBcjx5+2YPcsM0eJAcOcrdsyVoxYAUDc2RR D1zQLtlNdogNulvzCtvcH0az4pHuockJ3QMqKngtO+3aoQ2tb96RDaXvyMpp/gx8qdxA WGOCO4x6hH0Xl4axlexT8j07y0ed4f5hK95kwT3najPW6ddg0ZKh2lWXR8N/38vdQeWM miiLndTmJo+Y4ewXvpU45K81YvwJy5Ddb8S6NYT2JS9I60CD/r5G3t0X/9loMqJIuNeM nR4Vr8xvUl1WSS+maHm86etOVH9Yi9Iu5Y1P0xscUWQ82yqX7Q3gm/7qTwpXNCbzzKH1 w4pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ykA8VvGE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e7-20020a0568301f2700b005af373211e4si119927oth.56.2022.03.02.13.05.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Mar 2022 13:05:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ykA8VvGE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPWAE-0007CU-0x for patch@linaro.org; Wed, 02 Mar 2022 16:05:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPVxx-0005uQ-9m for qemu-devel@nongnu.org; Wed, 02 Mar 2022 15:52:57 -0500 Received: from [2a00:1450:4864:20::432] (port=39433 helo=mail-wr1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPVxv-0000Gf-N3 for qemu-devel@nongnu.org; Wed, 02 Mar 2022 15:52:57 -0500 Received: by mail-wr1-x432.google.com with SMTP id ay10so4678133wrb.6 for ; Wed, 02 Mar 2022 12:52:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=l/7EADgfQiDC7fxjtgYtq9X1xBlDjXtx1HGr/ZG8QYc=; b=ykA8VvGEZIbRQh0Vi4Uq1gtgxTDH+GkvZ1QU+QaoqxYAdV0woIaIqd6yplmeaEhQzB 2cTuETVow8yU+xPlzgfKgYVlkfuFJ7zlrOIjTOUFGP1Ts0w6ux0yjg8EjpGhle7zrst/ r1jRZV091MBlsfiaJLF1tnoNeGOmdVswVrzl5cc4yDevARqCe82hmS4+WSY5UQo133tB w18Qdtp3sHmJBdt6hHBqmDhc9BihFMzskMDuEBKpNMSNsHJP11EW8REwYUU3MsDsBKiS 6KKyXDkYt61b8AVfoJeCvEkIS4L3PAteu/c014cpghmow4xk1F0cEfuJL7MfObLPKZTn zpDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l/7EADgfQiDC7fxjtgYtq9X1xBlDjXtx1HGr/ZG8QYc=; b=20CnyfCBql/Kw5hmS0Vg9+ZPPZ4vpFsls4n5JWZrqpu92nO1+KNkj/xhG9j5dtsrFR ARPhhLOOhSiffaZmg9SdfxUpVLn/l2xoFUewcupmmN1bcPbvMhkHIdYOdLRqq1xMfL72 ePnSdOIhdanJ6vZC0hb8yvDXLaW1Vr1V5hwU/LFUDjEpUevY9ooVNvst6Oq5UAJMk5Xa QffngxQ3DxKlW2Nv+c4KWc0AX/gQPxRnVn2XEzyS+guOerVMxoIoeTshC996xLERHgbk 0VjsAm5YiPvygWKmbWQXL7Vv4yyzW0xAfXImiH7AIgZsARX5AKo3n3nT/AwKTvs0XTSL OdoQ== X-Gm-Message-State: AOAM531kodsQfozJGNpN1G2FrF2C4lEXmH9zEkOu+WiwlMFOn489p1pE fm4j5WEoEVzwM2HhYFHDWrLQJ9cCBSdX8g== X-Received: by 2002:a5d:5302:0:b0:1ed:e1d2:f0fd with SMTP id e2-20020a5d5302000000b001ede1d2f0fdmr24853768wrv.585.1646254373706; Wed, 02 Mar 2022 12:52:53 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id x13-20020adfec0d000000b001e31279cc38sm90801wrn.11.2022.03.02.12.52.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 12:52:53 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/26] target/arm: Report KVM's actual PSCI version to guest in dtb Date: Wed, 2 Mar 2022 20:52:28 +0000 Message-Id: <20220302205230.2122390-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302205230.2122390-1-peter.maydell@linaro.org> References: <20220302205230.2122390-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::432 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When we're using KVM, the PSCI implementation is provided by the kernel, but QEMU has to tell the guest about it via the device tree. Currently we look at the KVM_CAP_ARM_PSCI_0_2 capability to determine if the kernel is providing at least PSCI 0.2, but if the kernel provides a newer version than that we will still only tell the guest it has PSCI 0.2. (This is fairly harmless; it just means the guest won't use newer parts of the PSCI API.) The kernel exposes the specific PSCI version it is implementing via the ONE_REG API; use this to report in the dtb that the PSCI implementation is 1.0-compatible if appropriate. (The device tree binding currently only distinguishes "pre-0.2", "0.2-compatible" and "1.0-compatible".) Signed-off-by: Peter Maydell Reviewed-by: Marc Zyngier Reviewed-by: Akihiko Odaki Reviewed-by: Richard Henderson Reviewed-by: Andrew Jones Message-id: 20220224134655.1207865-1-peter.maydell@linaro.org --- target/arm/kvm-consts.h | 1 + hw/arm/boot.c | 5 ++--- target/arm/kvm64.c | 12 ++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/target/arm/kvm-consts.h b/target/arm/kvm-consts.h index e770921ddc2..faacf96fdc7 100644 --- a/target/arm/kvm-consts.h +++ b/target/arm/kvm-consts.h @@ -95,6 +95,7 @@ MISMATCH_CHECK(QEMU_PSCI_1_0_FN_PSCI_FEATURES, PSCI_1_0_FN_PSCI_FEATURES); #define QEMU_PSCI_VERSION_0_1 0x00001 #define QEMU_PSCI_VERSION_0_2 0x00002 +#define QEMU_PSCI_VERSION_1_0 0x10000 #define QEMU_PSCI_VERSION_1_1 0x10001 MISMATCH_CHECK(QEMU_PSCI_0_2_RET_TOS_MIGRATION_NOT_REQUIRED, PSCI_0_2_TOS_MP); diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 0eeef94ceb5..a47f38dfc90 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -488,9 +488,8 @@ static void fdt_add_psci_node(void *fdt) } qemu_fdt_add_subnode(fdt, "/psci"); - if (armcpu->psci_version == QEMU_PSCI_VERSION_0_2 || - armcpu->psci_version == QEMU_PSCI_VERSION_1_1) { - if (armcpu->psci_version == QEMU_PSCI_VERSION_0_2) { + if (armcpu->psci_version >= QEMU_PSCI_VERSION_0_2) { + if (armcpu->psci_version < QEMU_PSCI_VERSION_1_0) { const char comp[] = "arm,psci-0.2\0arm,psci"; qemu_fdt_setprop(fdt, "/psci", "compatible", comp, sizeof(comp)); } else { diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 64d48bfb19d..ccadfbbe72b 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -849,6 +849,7 @@ int kvm_arch_init_vcpu(CPUState *cs) uint64_t mpidr; ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; + uint64_t psciver; if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE || !object_dynamic_cast(OBJECT(cpu), TYPE_AARCH64_CPU)) { @@ -904,6 +905,17 @@ int kvm_arch_init_vcpu(CPUState *cs) } } + /* + * KVM reports the exact PSCI version it is implementing via a + * special sysreg. If it is present, use its contents to determine + * what to report to the guest in the dtb (it is the PSCI version, + * in the same 15-bits major 16-bits minor format that PSCI_VERSION + * returns). + */ + if (!kvm_get_one_reg(cs, KVM_REG_ARM_PSCI_VERSION, &psciver)) { + cpu->psci_version = psciver; + } + /* * When KVM is in use, PSCI is emulated in-kernel and not by qemu. * Currently KVM has its own idea about MPIDR assignment, so we