From patchwork Thu Apr 1 12:55:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 12178013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36F35C433B4 for ; Thu, 1 Apr 2021 12:57:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD64B61006 for ; Thu, 1 Apr 2021 12:57:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD64B61006 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRwsh-0003EM-Ps for qemu-devel@archiver.kernel.org; Thu, 01 Apr 2021 08:57:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRwrX-0001hE-9r for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:55:51 -0400 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]:46962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRwrV-0002xj-7X for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:55:51 -0400 Received: by mail-oi1-x236.google.com with SMTP id m13so1634333oiw.13 for ; Thu, 01 Apr 2021 05:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jf1VGujtece+sgrlTdeq9JiiLbbG5le4coO4jmGjzMs=; b=uJWJC90Fv3ZfmbNRq3PElKSAw+GkhitzXwH22LsbNIH0RAiT7H9ibTes7cnAWqcvWi VODHrHUx+TGfJJvejG3WadK527IcHhlgySFaQMOSwPC6PpOFF5E0oHWKmVWzoF0yixAB qW639gd+NAUgg4N52YRZsMWyShCzVb7ERZ4/3r2h/NGgZjcgRoYVabgFJ/aHZmpC2HRx frx6v1p9crcOj3mcbfK7cLmth4KW1Dya6BM2gxQcRv/f62XSlqJ2skpyNO/onIR8u0Ft lymtdn1jPOSYvaPwhPVHr+vl+EgJIce2OCimm34D45O4TnC1x3IpVDZvtUH8CWCaxCyW 1Kag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jf1VGujtece+sgrlTdeq9JiiLbbG5le4coO4jmGjzMs=; b=GCIo/VtcCMqN8sVB3x98BxJa9AF6jyxM26QDP6RLbq3M631UhP1FJ8CGgKLqCeJHve ARmhXCS/cK37eXdtAa1GWQMiF2ahAgAOfWYjEOvO9n36BRhqyE4Ly7zlW6RQKBuAhGH/ tucXwu6MD8Yh7f20Vhq5WJaGmIfLqGkD3g1jTx1eEIec/0VzAPKDQlsc8wNQEqoLA/yP x2hV+MF6b3o5Z4JzoMqhBlHvVQKjLX/jRHZPmXlagpjKJzMUghjHeE/5qINErsBQkGu3 6ygT8bgR0yl9F1ZyXdJsAFTkXKnPEaf+uEmRU+usF19jPsuf9SRbj8SMNsZgZ7yt5hAs Y6FQ== X-Gm-Message-State: AOAM531re8uDrSfvhpLM9snl4+HhC9o6u3zXxAV6pRybGnUGu2mZFBDs 0eyTVFJ0reM76ZXp+aMJhGwk79T8XQZYHHw= X-Google-Smtp-Source: ABdhPJzjQST9swZ1Ajtv8/20xozu3k76Wb0dZHepRGvjiQXJ7fmWyUd+18IsZdmNkdUVd8KHWaMszg== X-Received: by 2002:aca:4b4d:: with SMTP id y74mr5869561oia.97.1617281748104; Thu, 01 Apr 2021 05:55:48 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id w11sm1082245ooc.35.2021.04.01.05.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 05:55:47 -0700 (PDT) From: Haibo Xu To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Subject: [PATCH RESEND v2 1/6] Update linux header with new arm64 NV macro Date: Thu, 1 Apr 2021 12:55:33 +0000 Message-Id: <87d2a40fa0a6775dd5a6af9b0d1609c1bf2a9610.1617281290.git.haibo.xu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=haibo.xu@linaro.org; helo=mail-oi1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, richard.henderson@linaro.org, abologna@redhat.com, Haibo Xu , philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Haibo Xu --- linux-headers/asm-arm64/kvm.h | 2 ++ linux-headers/linux/kvm.h | 1 + 2 files changed, 3 insertions(+) diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index b6a0eaa32a..77b995a26c 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -106,6 +106,7 @@ struct kvm_regs { #define KVM_ARM_VCPU_SVE 4 /* enable SVE for this CPU */ #define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication */ #define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication */ +#define KVM_ARM_VCPU_HAS_EL2 7 /* Support nested virtualization */ struct kvm_vcpu_init { __u32 target; @@ -334,6 +335,7 @@ struct kvm_vcpu_events { #define KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS 6 #define KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO 7 #define KVM_DEV_ARM_VGIC_GRP_ITS_REGS 8 +#define KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ 9 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT 10 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_MASK \ (0x3fffffULL << KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 020b62a619..ce4630c4db 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1056,6 +1056,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190 #define KVM_CAP_SYS_HYPERV_CPUID 191 #define KVM_CAP_DIRTY_LOG_RING 192 +#define KVM_CAP_ARM_EL2 193 #ifdef KVM_CAP_IRQ_ROUTING From patchwork Thu Apr 1 12:55:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 12178017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5209C43460 for ; Thu, 1 Apr 2021 12:57:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BFD7611CB for ; Thu, 1 Apr 2021 12:57:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BFD7611CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRwsw-0003bk-GB for qemu-devel@archiver.kernel.org; Thu, 01 Apr 2021 08:57:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRwrY-0001hN-9e for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:55:52 -0400 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]:38673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRwrW-0002yI-9a for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:55:51 -0400 Received: by mail-oi1-x232.google.com with SMTP id v25so1670603oic.5 for ; Thu, 01 Apr 2021 05:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3J/atxW6sPYnXqaJSp9SobS3v6A+MNQfu9eol6wNQ30=; b=KLY2oOlZTJhTWb3UIrY7e18uqGaEK2xvaLysjy7MJtXDUs070MMjii5B4pBurCYFB9 qySEVXiBaIzM0zCr1wF5LRLFklKjryKdF4V+Ug1skqIkv8ikHCHm+kZ5tpmWtdi5UGu2 /97WcZu7SwcIDTJ9VvhwmCa4kSEfeYP9+39Ih4ic7s689TE6ePHfbRFrhhF6w6lgZUkI ZLw+KHl7q9hCrNC0agH+YU+Yts7W4j2ihJVWC4h/P2XxEFxRwJdARNVx+zRc61IRYOMr 5pYDPuQG8slq6+QpGrJpgfKnqoe9JhyDu/ob63LNibEFpMHwzlMII2tepurVV8KyYQge lNcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3J/atxW6sPYnXqaJSp9SobS3v6A+MNQfu9eol6wNQ30=; b=nGCtI3msWmXxwvdY8+8rzQYRV/wqyuhKiZwNJQo9l73SZImH8u4zJyriTI9jmq3bQG hUAyEFEqt3pmmzsa7WyP8/C6zHFfX92ad9wBb+15ngypOFeC+Ogs7gWB7eQ5/4YjrZ2H P+nF9asVpsgmt2lvO11g4vsL/AyNo7n2KND76nHaBNVWyjUvd0Ml3G4L0FgRny2Ff6OE HDGaGYmrJc8dBHrHPg2olfjgieiek6nyGidbjI+oCmbf+P3KzW5gAg7h9FQbLLJRFv3z 9dtT64d+gzLLisPGy1Q8PLG7NpH7GWoN7gdtTmSKKl1CWtmXPyaFSRqE4ddMAdkYR/nf E5MQ== X-Gm-Message-State: AOAM532IRfY/zMEB2By2l8oeWSXinszyUTC9QZhXmHd6Mf3Gp6ufGxM9 qyN3gQlFy8bZldUwyEd7cqEGF5KI6SibTyg= X-Google-Smtp-Source: ABdhPJyzuCI+gtU+a8SwPXa6zfIX3j+QFNSdGzYLeTURExLel2W4Zy/HnPcWvTa9wo31FcGnxAkNhA== X-Received: by 2002:aca:d514:: with SMTP id m20mr5850356oig.47.1617281749029; Thu, 01 Apr 2021 05:55:49 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id w11sm1082245ooc.35.2021.04.01.05.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 05:55:48 -0700 (PDT) From: Haibo Xu To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Subject: [PATCH RESEND v2 2/6] target/arm/kvm: Add helper to detect el2 when using KVM Date: Thu, 1 Apr 2021 12:55:34 +0000 Message-Id: <65b8771bfecada08bf02c9cf87c2f0f9cdf943b3.1617281290.git.haibo.xu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=haibo.xu@linaro.org; helo=mail-oi1-x232.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, richard.henderson@linaro.org, abologna@redhat.com, Haibo Xu , philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Haibo Xu Reviewed-by: Andrew Jones --- target/arm/kvm64.c | 5 +++++ target/arm/kvm_arm.h | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index dff85f6db9..9cacaf2eb8 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -721,6 +721,11 @@ bool kvm_arm_steal_time_supported(void) return kvm_check_extension(kvm_state, KVM_CAP_STEAL_TIME); } +bool kvm_arm_el2_supported(void) +{ + return kvm_check_extension(kvm_state, KVM_CAP_ARM_EL2); +} + QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN != 1); void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 34f8daa377..7d7fc7981b 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -285,6 +285,14 @@ void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp); */ bool kvm_arm_steal_time_supported(void); +/** + * kvm_arm_el2_supported: + * + * Returns: true if KVM can enable el2(nested virtualization) + * and false otherwise. + */ +bool kvm_arm_el2_supported(void); + /** * kvm_arm_aarch32_supported: * @@ -398,6 +406,11 @@ static inline bool kvm_arm_steal_time_supported(void) return false; } +static inline bool kvm_arm_el2_supported(void) +{ + return false; +} + /* * These functions should never actually be called without KVM support. */ From patchwork Thu Apr 1 12:55:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 12178027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 026D3C433ED for ; Thu, 1 Apr 2021 12:59:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6FF74611EF for ; Thu, 1 Apr 2021 12:59:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6FF74611EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRwvU-0006hb-Bm for qemu-devel@archiver.kernel.org; Thu, 01 Apr 2021 08:59:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRwrZ-0001jM-8k for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:55:53 -0400 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]:36821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRwrX-0002yh-Bf for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:55:52 -0400 Received: by mail-oi1-x234.google.com with SMTP id c16so1683343oib.3 for ; Thu, 01 Apr 2021 05:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+OpEDkbIB7gVmSFeUBZiFRPGe0lGXnIYEfiFDB8srwo=; b=CYVY4YuydGCWk0nJSlP1qJfy9o6yJBcE3EDK9jEIsAXofVhlRpOD2LhyrO+Bp/yjsy ngm18JleIuDltQgCDFeFMG1RMq1hraG4/9RbFTIJ8Yypz+BoGgs8eXFcCtiw4/vT4KNU 11h7sAGIYB0jrQ0VGx03UDyvuiv6n5rmFwQWrboO0KvGCtLjDjCDAmb/wi6upGxuvxOk Eq7PGSdHM8g6oUnO/C9J0GcB+tC9Gld4Sc3aQX6vQdSBgqv7HCPte1tVPT2HBPCpqNAo 4BHwd2e98+MothDGRxtYeBNbzXa7GMwN47vU7JR+6GGeDbTfsVUgX315EWoaABegdoGo +gXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+OpEDkbIB7gVmSFeUBZiFRPGe0lGXnIYEfiFDB8srwo=; b=ppfAYPoBlHrpuycbxwe4njk3Jhjjbvk752bCNOUDnJJ/wTUTYQWLqE2goKBRVCZU2W 76+raev5IBW6bbYY4Gbgu4YBT84TM89tYdhwkx4Wpej3GXUMj9BSgWOQTbtiKkI6TJ6+ klNdXHYpPOc50g8eUQeXEa5jwb3NGqomSVu0kGN4i8Ab9J+XHBowIeY9nB4gK9goNoCj dLhgLeAZ1ZxUlAh5FAYTunW902WxBcFaHzzNuutMK9BgAl9wMXuzGKx+2MM8TSujVcuG S11+rtP5tCUWtn2keweuapeksCIThVjY/vt7Ojal57S4NboMhvNjr35mCBrv9MbmddBj U4KQ== X-Gm-Message-State: AOAM530T8VroBoMCtfvaRMRA1UycfnTfxX7KvAz6l2hgQnhqfF96pzNq 2mQbN8UZCML+/Kf9p2PK+d7bbsE2+EIo8UY= X-Google-Smtp-Source: ABdhPJyjuGoajchkp6IaQLkRx33S6JPBejJ0IW2DVez2jVK4o3LvBBOyXsBqMUx2gShSUitFGQssJA== X-Received: by 2002:aca:df44:: with SMTP id w65mr5696005oig.36.1617281749967; Thu, 01 Apr 2021 05:55:49 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id w11sm1082245ooc.35.2021.04.01.05.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 05:55:49 -0700 (PDT) From: Haibo Xu To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Subject: [PATCH RESEND v2 3/6] target/arm/kvm: Add an option to turn on/off el2 support Date: Thu, 1 Apr 2021 12:55:35 +0000 Message-Id: <80d8bac17a21b41b36cde3eec6c9681b93f43d7c.1617281290.git.haibo.xu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::234; envelope-from=haibo.xu@linaro.org; helo=mail-oi1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, richard.henderson@linaro.org, abologna@redhat.com, Haibo Xu , philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Adds an el2=[on/off] option to enable/disable el2(nested virtualization) support in KVM guest vCPU. Signed-off-by: Haibo Xu --- target/arm/cpu.c | 11 ++++++++++ target/arm/cpu.h | 4 ++++ target/arm/cpu64.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ae04884408..30cc330f50 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1349,6 +1349,17 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) return; } } + + /* + * Currently, vCPU feature 'el2' only supported in KVM mode. + */ + if (kvm_enabled()) { + arm_cpu_el2_finalize(cpu, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + return; + } + } } if (kvm_enabled()) { diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 193a49ec7f..19fa9cfbfd 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -203,10 +203,12 @@ typedef struct { # define ARM_MAX_VQ 16 void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); +void arm_cpu_el2_finalize(ARMCPU *cpu, Error **errp); #else # define ARM_MAX_VQ 1 static inline void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) { } static inline void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { } +static inline void arm_cpu_el2_finalize(ARMCPU *cpu, Error **errp) { } #endif typedef struct ARMVectorReg { @@ -1058,6 +1060,7 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); void aarch64_sve_change_el(CPUARMState *env, int old_el, int new_el, bool el0_a64); void aarch64_add_sve_properties(Object *obj); +void aarch64_add_el2_properties(Object *obj); /* * SVE registers are encoded in KVM's memory in an endianness-invariant format. @@ -1089,6 +1092,7 @@ static inline void aarch64_sve_change_el(CPUARMState *env, int o, int n, bool a) { } static inline void aarch64_add_sve_properties(Object *obj) { } +static inline void aarch64_add_el2_properties(Object *obj) { } #endif void aarch64_sync_32_to_64(CPUARMState *env); diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index f0a9e968c9..3f3f2c5495 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -603,6 +603,58 @@ static Property arm_cpu_pauth_property = static Property arm_cpu_pauth_impdef_property = DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false); +void arm_cpu_el2_finalize(ARMCPU *cpu, Error **errp) +{ + if (cpu->has_el2) { + if (!kvm_enabled() || !kvm_arm_el2_supported()) { + error_setg(errp, "'el2' cannot be enabled on this host"); + return; + } + } + + if (cpu->has_el2) { + set_feature(&cpu->env, ARM_FEATURE_EL2); + } else { + unset_feature(&cpu->env, ARM_FEATURE_EL2); + } +} + +static bool arm_get_el2(Object *obj, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + + return cpu->has_el2; +} + +static void arm_set_el2(Object *obj, bool value, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + + if (value) { + if (!kvm_enabled() || !kvm_arm_el2_supported()) { + error_setg(errp, "'el2' cannot be enabled on this host"); + return; + } + set_feature(&cpu->env, ARM_FEATURE_EL2); + } else { + unset_feature(&cpu->env, ARM_FEATURE_EL2); + } + + cpu->has_el2 = value; +} + +void aarch64_add_el2_properties(Object *obj) +{ + /* + * vCPU feature 'el2' is only available in KVM mode, and is + * disabled by default to keep in line with that in TCG mode. + */ + ARM_CPU(obj)->has_el2 = false; + object_property_add_bool(obj, "el2", arm_get_el2, arm_set_el2); + object_property_set_description(obj, "el2", "Set off to disable " + "nested virtulization."); +} + /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); * otherwise, a CPU with as many features enabled as our emulation supports. * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; From patchwork Thu Apr 1 12:55:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 12178035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AEBDC433ED for ; Thu, 1 Apr 2021 13:04:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 97D87611F0 for ; Thu, 1 Apr 2021 13:04:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97D87611F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRx0A-0002vK-Hu for qemu-devel@archiver.kernel.org; Thu, 01 Apr 2021 09:04:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRwrb-0001nX-FQ for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:55:55 -0400 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]:41919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRwrY-0002zy-9p for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:55:55 -0400 Received: by mail-oi1-x22d.google.com with SMTP id z15so1652355oic.8 for ; Thu, 01 Apr 2021 05:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZOQB26mZhLmXCQu+JfKJIpuDxvkGsibNUVfx4FrnidQ=; b=KEvABx0NXKVvdh/cTK6KT1oo5zefKnn3hc69TWi2rxtInPtUacKaYNk3KgfhtWfjeo T4hCRoMYyjI2dGOe3OC37nXT2yKt8gTN8ewT+BjAqHOBfGsEinutKx3SNXezLAT0wO5K x11QqEEBzG5DSKKkNUnXZoifcye78z/7qtA++R4W51qS9Sgzc9Opq83NeFJ8BI4ijXFp waTiFea9FnnYxoEtL23AehWyXbDZnNd413K4o2vca32gnjZ+kxy1gAc96mBv+F20bMnn pAgjWwMgEB/vR2jYWj0f+PjF60b5zWNvbQZxbixcob4cw0S3K7O9IjLdkPLn5CJ2DkQn OewQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZOQB26mZhLmXCQu+JfKJIpuDxvkGsibNUVfx4FrnidQ=; b=RJ/cYM8n2fRw0U94tPZAxv9Ie0kf5/Yw5MLRd0bpppwYtJH6iprNO6Rje7RawrarqP THTT/2RwD3SnvH9/vT03K8b9rpfX/XgBYvDFmwkeUMVLnNQB33COa1QfqopUKp6OcbWD htHnQKjBmzrptRJT0dFVttE7oKce7NxVBzH/BzkxHs/HTD2bCXHMLJ+y846Uk7Bz0UGD htysV8040n0xiVWS6pCBFXZpvtkPOaU5hy1BaPYfUXMYY+qEKSpHlflTrnpbIW41E5Zz sgENniEdmOEhjLntWUY0TQsPhiVYDpNzEiboRinmSmw4De49crPmqoL1gYoUT4OArsLL u5wA== X-Gm-Message-State: AOAM532HvIMDmXXe9UYDtpIsbKU0YPYQFXZQIGGX2r0+LS4rauRruo2Z f7sfnbRY8qCUTOlGaC2tpaBNaGFYv4/WrW0= X-Google-Smtp-Source: ABdhPJxI/uw6rbji0Wl5bpHt1oA9wrU1QLTCRJ5Nd+hBlIOxas0NY1cKepceiGfY8WNhVaQnin+Mow== X-Received: by 2002:aca:4c48:: with SMTP id z69mr6220512oia.61.1617281750888; Thu, 01 Apr 2021 05:55:50 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id w11sm1082245ooc.35.2021.04.01.05.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 05:55:50 -0700 (PDT) From: Haibo Xu To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Subject: [PATCH RESEND v2 4/6] hw/intc/arm_gicv3: Enable support for setting vGIC maintenance IRQ Date: Thu, 1 Apr 2021 12:55:36 +0000 Message-Id: <49a4944e2f148c56938380b981afe154b7a8b7ee.1617281290.git.haibo.xu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22d; envelope-from=haibo.xu@linaro.org; helo=mail-oi1-x22d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, richard.henderson@linaro.org, abologna@redhat.com, Haibo Xu , philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Using the new VGIC KVM device attribute to set the maintenance IRQ. This is fixed to use IRQ 25(PPI 9), as a platform decision matching the arm64 SBSA recommendation. Signed-off-by: Haibo Xu --- hw/arm/virt.c | 5 +++++ hw/intc/arm_gicv3_common.c | 1 + hw/intc/arm_gicv3_kvm.c | 16 ++++++++++++++++ include/hw/intc/arm_gicv3_common.h | 1 + 4 files changed, 23 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index aa2bbd14e0..92d46ebcfe 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -663,6 +663,11 @@ static void create_gic(VirtMachineState *vms) qdev_prop_set_uint32(vms->gic, "redist-region-count[1]", MIN(smp_cpus - redist0_count, redist1_capacity)); } + + if (kvm_irqchip_in_kernel()) { + bool el2 = object_property_get_bool(OBJECT(first_cpu), "el2", NULL); + qdev_prop_set_bit(vms->gic, "has-virtualization-extensions", el2); + } } else { if (!kvm_irqchip_in_kernel()) { qdev_prop_set_bit(vms->gic, "has-virtualization-extensions", diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index 58ef65f589..3ac10c8e61 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -495,6 +495,7 @@ static Property arm_gicv3_common_properties[] = { DEFINE_PROP_UINT32("num-irq", GICv3State, num_irq, 32), DEFINE_PROP_UINT32("revision", GICv3State, revision, 3), DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0), + DEFINE_PROP_BOOL("has-virtualization-extensions", GICv3State, virt_extn, 0), DEFINE_PROP_ARRAY("redist-region-count", GICv3State, nb_redist_regions, redist_region_count, qdev_prop_uint32, uint32_t), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 65a4c880a3..1e1ca66e2c 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -826,6 +826,22 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true, &error_abort); + if (s->virt_extn) { + bool maint_irq_allowed; + uint32_t maint_irq = 25; + + maint_irq_allowed = + kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ, 0); + if (!maint_irq_allowed) { + error_setg(errp, "VGICv3 setting maintenance IRQ are not " + "supported by this host kernel"); + return; + } + + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ, + 0, &maint_irq, true, &error_abort); + } + kvm_arm_register_device(&s->iomem_dist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR, KVM_VGIC_V3_ADDR_TYPE_DIST, s->dev_fd, 0); diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h index 91491a2f66..921ddc2c5f 100644 --- a/include/hw/intc/arm_gicv3_common.h +++ b/include/hw/intc/arm_gicv3_common.h @@ -220,6 +220,7 @@ struct GICv3State { uint32_t num_irq; uint32_t revision; bool security_extn; + bool virt_extn; bool irq_reset_nonsecure; bool gicd_no_migration_shift_bug; From patchwork Thu Apr 1 12:55:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 12178025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8D32C433ED for ; Thu, 1 Apr 2021 12:59:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 58AB960FDC for ; Thu, 1 Apr 2021 12:59:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58AB960FDC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRwvK-0006JL-CS for qemu-devel@archiver.kernel.org; Thu, 01 Apr 2021 08:59:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRwrb-0001nY-Fk for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:55:55 -0400 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]:37748) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRwrZ-00031c-6c for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:55:55 -0400 Received: by mail-ot1-x336.google.com with SMTP id t23-20020a0568301e37b02901b65ab30024so2021377otr.4 for ; Thu, 01 Apr 2021 05:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7GP5EWBOufrga+3kB4LulNdONpwe1B1Vve3c5Unp/SM=; b=yayEFpLPNYip1GCy16wSJRHJfojBH5pUhE2e/jfvlLPbs9lqNWIVXPmr7DipEBmfqq 84sDLN2N9IHc1K+XqAhvIH95CLAa1jH/A2WgBwCRbkve+pA1SPYJaHVL8hJpf1vy12Tq I7f24Zw2LRNLUkVt05KO99iQz6fkKwfNUpf7/yC9XXnvp7Td2k26uu4u4lPJlDog6VoD dxVCHjSgIM78aoF/39y+mzS2xtBqhpQ2t1i8GqLJWkAdRSZUxnhZtQ3vw6vJfssOjx+e YlJOelMHiToWo3s5mMkcJsjkUGZO49eIwqHZWHVGK8vvdSjOK/EVBR9IlkFjaw0eM+1l /kOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7GP5EWBOufrga+3kB4LulNdONpwe1B1Vve3c5Unp/SM=; b=qhoIRaigJGj6KaU2pRCAVAIg25Q/ISkHUIFy244395hQksDxqJWFCmAC8L/+rWQfGG dAwGU0YVLkCbWiVc2BgRZ8R5AwBoR+PA/mMXN6Z5DqmT0uCyoKobikKQ9CTl8yH6bqKV 38L6MSkD3LpgAQN5/udGNNSJZI3Oaq6nm6SfpJuC+rjoDHUkRjGZOze6plh3y8wR0VfJ zMkHZA9hMnn57I6a6n8AqPc8aOLMEjPI7AceQMeyKbVIiyI7d/3Su1Ul/x5xzVRVgaYm vaEI4mdX2KaOYgqXxtfpl0TFn4d3nL5oATw5yTGrEzwhhD2gl54DLQLxAKNZcHOoC8zu O3lg== X-Gm-Message-State: AOAM533zq4bc5om3caxKmOhUslkOlC+ZtEGhN/oxkHrEbFt8c9B41SYB T2OQSSjwul/8em6gcCXQsxOL4ooX/En4ce8= X-Google-Smtp-Source: ABdhPJy2E1ToDg77tARBkFR8deNoEr9mPMdEhdUqK4xzisMxsjdtcyJJcxW8Mui6snPb4Y6/5YpNOg== X-Received: by 2002:a9d:3c2:: with SMTP id f60mr7028094otf.220.1617281751764; Thu, 01 Apr 2021 05:55:51 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id w11sm1082245ooc.35.2021.04.01.05.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 05:55:51 -0700 (PDT) From: Haibo Xu To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Subject: [PATCH RESEND v2 5/6] target/arm/cpu: Enable 'el2' to work with host/max cpu Date: Thu, 1 Apr 2021 12:55:37 +0000 Message-Id: <37df1b1872f15086dd1d066e53dc1eedaf114051.1617281290.git.haibo.xu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::336; envelope-from=haibo.xu@linaro.org; helo=mail-ot1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, richard.henderson@linaro.org, abologna@redhat.com, Haibo Xu , philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Turn off the 'el2' cpu property by default to keep in line with that in TCG mode, i.e. we can now use '-cpu max|host,el2=on' to enable the nested virtualization. Signed-off-by: Haibo Xu --- hw/arm/virt.c | 14 ++++++++++---- target/arm/cpu.c | 3 ++- target/arm/cpu64.c | 1 + target/arm/kvm64.c | 10 ++++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 92d46ebcfe..74340e21bd 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -454,6 +454,7 @@ static void fdt_add_gic_node(VirtMachineState *vms) { MachineState *ms = MACHINE(vms); char *nodename; + bool has_el2 = object_property_get_bool(OBJECT(first_cpu), "el2", NULL); vms->gic_phandle = qemu_fdt_alloc_phandle(ms->fdt); qemu_fdt_setprop_cell(ms->fdt, "/", "interrupt-parent", vms->gic_phandle); @@ -491,7 +492,7 @@ static void fdt_add_gic_node(VirtMachineState *vms) 2, vms->memmap[VIRT_HIGH_GIC_REDIST2].size); } - if (vms->virt) { + if (vms->virt || has_el2) { qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts", GIC_FDT_IRQ_TYPE_PPI, ARCH_GIC_MAINT_IRQ, GIC_FDT_IRQ_FLAGS_LEVEL_HI); @@ -1911,8 +1912,8 @@ static void machvirt_init(MachineState *machine) } if (vms->virt && kvm_enabled()) { - error_report("mach-virt: KVM does not support providing " - "Virtualization extensions to the guest CPU"); + error_report("mach-virt: VM 'virtualization' feature is not supported " + "in KVM mode, please use CPU feature 'el2' instead"); exit(1); } @@ -1950,11 +1951,16 @@ static void machvirt_init(MachineState *machine) object_property_set_bool(cpuobj, "has_el3", false, NULL); } - if (!vms->virt && object_property_find(cpuobj, "has_el2")) { + if (!vms->virt && !kvm_enabled() && + object_property_find(cpuobj, "has_el2")) { object_property_set_bool(cpuobj, "has_el2", false, NULL); } if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED) { + if (kvm_enabled() && ARM_CPU(cpuobj)->has_el2) { + vms->psci_conduit = QEMU_PSCI_CONDUIT_SMC; + } + object_property_set_int(cpuobj, "psci-conduit", vms->psci_conduit, NULL); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 30cc330f50..9530a2c4bf 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1099,7 +1099,7 @@ static Property arm_cpu_rvbar_property = #ifndef CONFIG_USER_ONLY static Property arm_cpu_has_el2_property = - DEFINE_PROP_BOOL("has_el2", ARMCPU, has_el2, true); + DEFINE_PROP_BOOL("has_el2", ARMCPU, has_el2, false); static Property arm_cpu_has_el3_property = DEFINE_PROP_BOOL("has_el3", ARMCPU, has_el3, true); @@ -2018,6 +2018,7 @@ static void arm_host_initfn(Object *obj) kvm_arm_set_cpu_features_from_host(cpu); if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { aarch64_add_sve_properties(obj); + aarch64_add_el2_properties(obj); } arm_cpu_post_init(obj); } diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 3f3f2c5495..ae8811d09e 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -666,6 +666,7 @@ static void aarch64_max_initfn(Object *obj) if (kvm_enabled()) { kvm_arm_set_cpu_features_from_host(cpu); + aarch64_add_el2_properties(obj); } else { uint64_t t; uint32_t u; diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 9cacaf2eb8..7bf892404f 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -500,6 +500,7 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) */ int fdarray[3]; bool sve_supported; + bool el2_supported; uint64_t features = 0; uint64_t t; int err; @@ -646,6 +647,7 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) } sve_supported = ioctl(fdarray[0], KVM_CHECK_EXTENSION, KVM_CAP_ARM_SVE) > 0; + el2_supported = ioctl(fdarray[0], KVM_CHECK_EXTENSION, KVM_CAP_ARM_EL2) > 0; kvm_arm_destroy_scratch_host_vcpu(fdarray); @@ -660,6 +662,11 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ahcf->isar.id_aa64pfr0 = t; } + /* Use the ARM_FEATURE_EL2 bit to keep inline with that in TCG mode. */ + if (el2_supported) { + features |= 1ULL << ARM_FEATURE_EL2; + } + /* * We can assume any KVM supporting CPU is at least a v8 * with VFPv4+Neon; this in turn implies most of the other @@ -861,6 +868,9 @@ int kvm_arch_init_vcpu(CPUState *cs) assert(kvm_arm_sve_supported()); cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE; } + if (arm_feature(&cpu->env, ARM_FEATURE_EL2)) { + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_HAS_EL2; + } /* Do KVM_ARM_VCPU_INIT ioctl */ ret = kvm_arm_vcpu_init(cs); From patchwork Thu Apr 1 12:55:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 12178031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21054C433B4 for ; Thu, 1 Apr 2021 13:01:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 84C02611EF for ; Thu, 1 Apr 2021 13:01:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84C02611EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRwxO-00088Y-GS for qemu-devel@archiver.kernel.org; Thu, 01 Apr 2021 09:01:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRwrj-0001tU-8Y for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:56:05 -0400 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]:36819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRwrZ-00031u-Vh for qemu-devel@nongnu.org; Thu, 01 Apr 2021 08:56:02 -0400 Received: by mail-oi1-x231.google.com with SMTP id c16so1683427oib.3 for ; Thu, 01 Apr 2021 05:55:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JjlPaXyuxmJc78UBaRD26ugJ56+ZZ/y7y6+y5dorLqk=; b=XgvyIi4RtYw1km+tBhq8U0qH/EaSjqKNKHdION7K73Z8gA+VDSTl820c5rWoGa3JBu 0jN/GKDaIJIHJUbsmRBo5V+0taB1D8xagQ/QSc90YilIBbpuUbH2f/JSciXvdfcpDI7C cY1WNB3XiiofamElZiGMjiijA+crgkdwbvaYFeqaGndhNnG4UoNnRlCjfSHo4F5anE0s hdKcMQ7mT23yXBm6RoFB2GdnhiRTJB8yZfQy0nlFdC424PfXwGJjIItaY1qBpoGsisd6 bEdfF9ATHMZ2k65CiTCNdNM3HbKLZmT9vuiAMSpUzY1g9pSheAsEgkOBpiJDjZ1iKGcR ldxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JjlPaXyuxmJc78UBaRD26ugJ56+ZZ/y7y6+y5dorLqk=; b=fbhJDPXth8J6+TvseVHC08on6aNlJclEgc5BZkj8uEWYESjOKKorKYqVm2ygJrjhxe OIYxiKOqC9i2d6b1oBpcbiwTTp/qm6ATJDCXTI/icLH1csYMkU797NGnd6WSTHRKF5lg CC9SmRoDtD9PvuGJoOdptBDDix5Vnbv22A5+7I8WpVZHDdAD4l55WHQMHsh9cSPWk0QQ gASZBFOb4ydT7xhiRza6D7mtSS9ScwatQbdtru8pRu2bOmpn78V9p4LX5ntrYNHeZsLx nQdkId09BYNsQl9YptyexMkJ9EbwbNZ+px2nbzyuTP40h6w2lvTh7E5y8/vAjV26nWDT uJaw== X-Gm-Message-State: AOAM5329X8Gvj6bbsXm/PxUuO7w2LXnr4mUjGpYOhbHuw1Rvsr446Xqn +cmTb+62th8uM9uFQaJ4GIassjLx6R4WyRI= X-Google-Smtp-Source: ABdhPJzLBPi6mayc6/vYAk9lDVKfWPhciOGsM08z6My0FasFOBNVJQLT1J70niGjGXwysBO8xaH9xA== X-Received: by 2002:aca:fc11:: with SMTP id a17mr5776781oii.68.1617281752660; Thu, 01 Apr 2021 05:55:52 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id w11sm1082245ooc.35.2021.04.01.05.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 05:55:52 -0700 (PDT) From: Haibo Xu To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Subject: [PATCH RESEND v2 6/6] target/arm: Add vCPU feature 'el2' test. Date: Thu, 1 Apr 2021 12:55:38 +0000 Message-Id: <50db1700b4df48acbecfda077b2220a0e3cf6b49.1617281290.git.haibo.xu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::231; envelope-from=haibo.xu@linaro.org; helo=mail-oi1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, richard.henderson@linaro.org, abologna@redhat.com, Haibo Xu , philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Haibo Xu --- target/arm/monitor.c | 2 +- tests/qtest/arm-cpu-features.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/target/arm/monitor.c b/target/arm/monitor.c index 80c64fa355..6c39238925 100644 --- a/target/arm/monitor.c +++ b/target/arm/monitor.c @@ -90,7 +90,7 @@ QEMU_BUILD_BUG_ON(ARM_MAX_VQ > 16); * then the order that considers those dependencies must be used. */ static const char *cpu_model_advertised_features[] = { - "aarch64", "pmu", "sve", + "aarch64", "pmu", "sve", "el2", "sve128", "sve256", "sve384", "sve512", "sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280", "sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048", diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c index 8252b85bb8..be07bf0c76 100644 --- a/tests/qtest/arm-cpu-features.c +++ b/tests/qtest/arm-cpu-features.c @@ -509,6 +509,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data) if (g_str_equal(qtest_get_arch(), "aarch64")) { bool kvm_supports_steal_time; bool kvm_supports_sve; + bool kvm_supports_el2; char max_name[8], name[8]; uint32_t max_vq, vq; uint64_t vls; @@ -533,10 +534,12 @@ static void test_query_cpu_model_expansion_kvm(const void *data) */ assert_has_feature(qts, "host", "kvm-steal-time"); assert_has_feature(qts, "host", "sve"); + assert_has_feature(qts, "host", "el2"); resp = do_query_no_props(qts, "host"); kvm_supports_steal_time = resp_get_feature(resp, "kvm-steal-time"); kvm_supports_sve = resp_get_feature(resp, "sve"); + kvm_supports_el2 = resp_get_feature(resp, "el2"); vls = resp_get_sve_vls(resp); qobject_unref(resp); @@ -602,11 +605,17 @@ static void test_query_cpu_model_expansion_kvm(const void *data) } else { g_assert(vls == 0); } + + if (kvm_supports_el2) { + assert_set_feature(qts, "host", "el2", false); + assert_set_feature(qts, "host", "el2", true); + } } else { assert_has_not_feature(qts, "host", "aarch64"); assert_has_not_feature(qts, "host", "pmu"); assert_has_not_feature(qts, "host", "sve"); assert_has_not_feature(qts, "host", "kvm-steal-time"); + assert_has_not_feature(qts, "host", "el2"); } qtest_quit(qts);