From patchwork Fri Aug 7 08:10:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 247538 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2232521ilo; Fri, 7 Aug 2020 01:12:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWH0aOLNcxZrnF5/evUDBNmDjCop9derfl/Cx7AbB7zFGsuqCjLRJdJJS5verBmGo+Z5fR X-Received: by 2002:a25:6612:: with SMTP id a18mr19826115ybc.267.1596787930024; Fri, 07 Aug 2020 01:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596787930; cv=none; d=google.com; s=arc-20160816; b=oE8+O4f3ST7rmx3X4hD6bRlgKzG4ihD640X3R6m1ndcc/Ntg0JrHvEjmnZrD3apXZe 90yZg3oDLiQpWPgM4mor1rpstu/+djMH3QA/mGvAvkCv7Hlt35dEt/3WfGkAml58eWTe jmD2GfjGe8aRJ/CpSdQIw+GEVZ2hY6fT59ZWLEOqNIPd5fTFOaBy+wTCPtcRmlhfngwh t7+HZIaFecrz+zmiCyL5Lc4Oj4m1xzyd5dMyL1rQvCCtJhq75uIU9zFp6vGQ8LWku6lk bFqeOJYHCfqFDcVM6yvPI4nV8Ib7h/0kuZXNGC9F3bTSOYlYxEsPReYZ4lgYYsnHhdcA evig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=SVvavflqwBHyVfPeo3WkPtz2sD2s7cZLSNZLl+ZfUO0=; b=nTIxX0SuypPJ7yi3q1bvlzB//qzHOyuIYSAHKbS8yPqJ1nzZbs37sonPyB7AYSLZEH ZNJh2QP+kdBNs6gppRQHUN0oCR7INkhjQ9e8ZSG6QWUIMrSxeAq7JRRgse9PJfVpgiv3 ie7EVtm3kXe31wC87m5rvEJrE1/JCHj7cyHuOSVpz9DmoznbQ2rcSxwLul9DZ+4cojH+ oIlk9gFUxAnetureE21p1wlAHTm60xX1n9k8IsqoZ3O2cEjR4z9POKrEness4xbMk0Zo udPLutdAbf8cxLKPhBb48OlsNIjyE+h8XAI9n7JP5BwQsrEtpbbB/y/GgdOHwuWxmZUV BZLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hCzc8Gm9; 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=fail (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 x12si7152153ybr.115.2020.08.07.01.12.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Aug 2020 01:12:10 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=hCzc8Gm9; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3xU1-0000aN-HF for patch@linaro.org; Fri, 07 Aug 2020 04:12:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3xSf-00070N-QL for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:45 -0400 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]:41444) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3xSc-0001h6-EG for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:45 -0400 Received: by mail-io1-xd33.google.com with SMTP id g19so1057948ioh.8 for ; Fri, 07 Aug 2020 01:10:41 -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=SVvavflqwBHyVfPeo3WkPtz2sD2s7cZLSNZLl+ZfUO0=; b=hCzc8Gm9b7h0j1Hij+WDaaowmrvNimX4GLIJ5eYjCHwjLaascuNQMt4q+J1JY/4Egr uYe8ayQhzwq6LZ0iGU+UFPdVhqcOygM+IVAGdQMAP71UCUtiB6XDeHv0i3ktSYYwr2uP eMtQw6Si0k/wMY5beDVkS8SlIpYS/3B+4WGpvmBdKYa1Cu5fJnsnWSKN9D9L/wedDaq4 QJid3NW4x6U0Cet/0OgnNq78Q0N7ShXFVbK4GKGz+TBuYPbyyTjCFjn+Tse0rA6yDURL jxd3Mk9CohNsdBvLw++zalcMUvml5kuc4NDbB1bSTtQc3eo7a2RxvyUf/CU/h/Glh5Zd 1vfg== 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=SVvavflqwBHyVfPeo3WkPtz2sD2s7cZLSNZLl+ZfUO0=; b=PSgN7oeBkaKY3+BZ5WMjAUTEcldEcXip7Wst4WKHsFV59qFQYLPCKQ9Lm2yZAOXEMN BDHiLXRk6E0jjKj/r9RNffGRIARWg2Lf9J6ODEHIt6Ak0fpRFc9v8qoG2ma3WLu1vsYx hjYnRLjPs1qh9aPgpdOevAeWHa7msqEUwaW1Fhh2hIudcD9bjesumyyuaJY4pusEBL6u su6pr2QaWrbYK/mgOYZdyZWP2JMg6K5GYHvtFynfO+DYp6QzvvwKHLhvy+MYzGU0V3/w dckNdxQaFC/NxoXC4CLl8poheFwcShBeIMtPrSV6tpdk8kGxdt0NywXuK98kheHZ5Ajx ZiJQ== X-Gm-Message-State: AOAM53018rkNm5AzX3mSCnOv3iAJq+bzhD9IX03xipNxdD9NGyPlHdnX v8g9tz5GcCOAZBWJ09bRbrFN X-Received: by 2002:a6b:8b10:: with SMTP id n16mr3242360iod.11.1596787841141; Fri, 07 Aug 2020 01:10:41 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id l144sm6233546ill.6.2020.08.07.01.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 01:10:40 -0700 (PDT) From: Haibo Xu To: peter.maydell@linaro.org Subject: [PATCH 1/7] update Linux headers with new vSPE macros Date: Fri, 7 Aug 2020 08:10:31 +0000 Message-Id: <4da5af14d6f0c0adb112d04eafa0a488ab924439.1596768588.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::d33; envelope-from=haibo.xu@linaro.org; helo=mail-io1-xd33.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: drjones@redhat.com, qemu-arm@nongnu.org, philmd@redhat.com, qemu-devel@nongnu.org, Haibo Xu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Haibo Xu --- linux-headers/asm-arm64/kvm.h | 4 ++++ linux-headers/linux/kvm.h | 2 ++ 2 files changed, 6 insertions(+) -- 2.17.1 diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index 9e34f0f875..802319ee02 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_SPE_V1 7 /* Support guest SPEv1 */ struct kvm_vcpu_init { __u32 target; @@ -334,6 +335,9 @@ struct kvm_vcpu_events { #define KVM_ARM_VCPU_TIMER_IRQ_PTIMER 1 #define KVM_ARM_VCPU_PVTIME_CTRL 2 #define KVM_ARM_VCPU_PVTIME_IPA 0 +#define KVM_ARM_VCPU_SPE_V1_CTRL 3 +#define KVM_ARM_VCPU_SPE_V1_IRQ 0 +#define KVM_ARM_VCPU_SPE_V1_INIT 1 /* KVM_IRQ_LINE irq field index values */ #define KVM_ARM_IRQ_VCPU2_SHIFT 28 diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index a28c366737..35ef0ae842 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1031,6 +1031,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_PPC_SECURE_GUEST 181 #define KVM_CAP_HALT_POLL 182 #define KVM_CAP_ASYNC_PF_INT 183 +#define KVM_CAP_ARM_SPE_V1 184 #ifdef KVM_CAP_IRQ_ROUTING @@ -1671,6 +1672,7 @@ struct kvm_assigned_msix_entry { #define KVM_ARM_DEV_EL1_VTIMER (1 << 0) #define KVM_ARM_DEV_EL1_PTIMER (1 << 1) #define KVM_ARM_DEV_PMU (1 << 2) +#define KVM_ARM_DEV_SPE (1 << 3) struct kvm_hyperv_eventfd { __u32 conn_id; From patchwork Fri Aug 7 08:10:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 247542 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2233521ilo; Fri, 7 Aug 2020 01:14:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeJKk1CpuKzQ32ot1+Hd8JcDopV/SUWRELu758h+3KmbzVeKmfBrDV1DsFGZUiMUN0a8b8 X-Received: by 2002:a25:4b47:: with SMTP id y68mr16839336yba.89.1596788042757; Fri, 07 Aug 2020 01:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596788042; cv=none; d=google.com; s=arc-20160816; b=L8DwvpBlq2IdF42emwhaBv74OtkcjSckDOxZTSwgCD75IVYQRDWWYoyf7GRbpIqT7h FmzKssgU9J7811I63QEBNUZdMAaSXt1+z1B8kbU7VeHjQkGVM4VKxtNg10AgSrR1egNh GPoIXCbjP+/I/1jBCRdFxwR+YiiSHk9pPLn0rWRUzA8o0YScDms7ZjdhG+J/LraJeScj aZdDCnywLGK9g8Bdloyils/r4GGrCE9cijUMQNvmlmOn1BU2RRMGoA8yA39vbOsfl4NY 119dhv3l4/Lm36N54h45ofdcnXs5ZIFhmTZGIzC09LB4T9wmuLkPo7vQ/WDxzHK3OdwS 81GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=9aB5SJHC8FbDBha6sRb/HKsg3SmMO8+j3TVfCLWuY0I=; b=Lim1uZiTVrQFi6RBp8Px7BfkCC51I4IZ+d0SjIR3GSapfP2zoQB0Uwy6kJCrNMzXqi NmPAzwEHNT1HxCn2L8o7DVFloB47D7JYXJLXsnbLFlgerKHFlsGQhEFxCFQDf2Q4CicL xBya79rukag781fOOfWeYwBvKEFN1yOoiuIDzx5Ux8YuA2vF5PhcXLCzMoJoG909yy9o 3rWP5H+T9BeoUH6j4xUeWtmyppAgMxD1Lsmppk6NAs3nL6OkvY/GMNWAxeV9Ejr9wCCz jCjis1z6phhAq/JqFsiMfzBzsRX1vh2LIHH7s0VgC/9ZOLCEFvJKxOjpNj9k/aEAm1Gh a99w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VMRerHch; 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=fail (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 c186si7494021yba.330.2020.08.07.01.14.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Aug 2020 01:14:02 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=VMRerHch; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3xVq-00041w-3d for patch@linaro.org; Fri, 07 Aug 2020 04:14:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3xSg-00073r-Ut for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:46 -0400 Received: from mail-il1-x141.google.com ([2607:f8b0:4864:20::141]:46970) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3xSc-0001hN-Rx for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:46 -0400 Received: by mail-il1-x141.google.com with SMTP id c6so1053721ilo.13 for ; Fri, 07 Aug 2020 01:10:42 -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=9aB5SJHC8FbDBha6sRb/HKsg3SmMO8+j3TVfCLWuY0I=; b=VMRerHchoWHr6rI5g1T1wBXEAV08CskMGvdTstVSKB1XxOvhzZ3/tIF/aOWYqm0zJi KOgIgp4cS890MoVcBHUhGd61D3p2blbo5YJ0VcGA1sr30zKXcR3SL9R65GjTDYWvkYuw QEaBck9wT8PcjJxo9A6b7VOYyeVBQ/pY6mFEuFgVj1i9/C0CHB2FHo8Uzu+fBA/wsw1+ GrFcPBz8szdvlRgMJtN719v4Q4fCYKE5xx77k5IbJnMqmpu00RFFTr3V/rtnVi8+3iMP V2zSdFakfE/WlUnkpWK6b+xu67XLfZ3QO1rM+EQyHirsyJY8TELx4axKy3czRwEOLVEV RW9w== 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=9aB5SJHC8FbDBha6sRb/HKsg3SmMO8+j3TVfCLWuY0I=; b=B5lhom2qE4IeV+dTqdYLm5uyKxsXmzBIr1sp5VzlCJmyLRHJsFOgrwGfjdNTetgW23 5cj1ZoCl+K54ygJKALnyNqJpwZTjBQIr8ZI3K6xWaEs6iR/Kyy/FynEYYYXkl7FKKWum uz6bHofIbhxPTtdeZaSs+Vn+auPGcgMh17+Uso/omycpXgHrntmnR13ifgOp1Vlb1SDu GLTTKucB8C47/4H0zXW4IUoSoozIXqN6kzZltVWh5BF/Da2gzTS95ggZNTy0+6HPDM8U Dtw/QXfOfB4ZuCrPD8AigQWuwaLY0joPXuXIqwkveGH6aNW9YzzI3J3LeWR6fn468dCd g5VA== X-Gm-Message-State: AOAM530AAlpOCqyziMe1IMuAnF361oo50nvARd0iYiqOWfH8JT08ryyN 61qIQXix9jKvfNpxKEq0JD7C X-Received: by 2002:a92:c74a:: with SMTP id y10mr3126240ilp.306.1596787841901; Fri, 07 Aug 2020 01:10:41 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id l144sm6233546ill.6.2020.08.07.01.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 01:10:41 -0700 (PDT) From: Haibo Xu To: peter.maydell@linaro.org Subject: [PATCH 2/7] target/arm/kvm: spe: Add helper to detect SPE when using KVM Date: Fri, 7 Aug 2020 08:10:32 +0000 Message-Id: <76aa68f9ec73ced85070b81ef5251771ca27d072.1596768588.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::141; envelope-from=haibo.xu@linaro.org; helo=mail-il1-x141.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: drjones@redhat.com, qemu-arm@nongnu.org, philmd@redhat.com, qemu-devel@nongnu.org, Haibo Xu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Haibo Xu --- target/arm/kvm.c | 5 +++++ target/arm/kvm_arm.h | 13 +++++++++++++ 2 files changed, 18 insertions(+) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 8bb7318378..58f991e890 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -214,6 +214,11 @@ bool kvm_arm_pmu_supported(void) return kvm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3); } +bool kvm_arm_spe_supported(void) +{ + return kvm_check_extension(kvm_state, KVM_CAP_ARM_SPE_V1); +} + int kvm_arm_get_max_vm_ipa_size(MachineState *ms) { KVMState *s = KVM_STATE(ms->accelerator); diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index adb38514bf..f79655674e 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -283,6 +283,14 @@ bool kvm_arm_aarch32_supported(void); */ bool kvm_arm_pmu_supported(void); +/** + * kvm_arm_spe_supported: + * + * Returns: true if the KVM VCPU can enable its SPE + * and false otherwise. + */ +bool kvm_arm_spe_supported(void); + /** * kvm_arm_sve_supported: * @@ -366,6 +374,11 @@ static inline bool kvm_arm_pmu_supported(void) return false; } +static inline bool kvm_arm_spe_supported(void) +{ + return false; +} + static inline bool kvm_arm_sve_supported(void) { return false; From patchwork Fri Aug 7 08:10:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 247540 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2232822ilo; Fri, 7 Aug 2020 01:12:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwymb9CoeaEcwd1yDeraQOlPNLHPuEZI6dtf5Mil0vct+TBHPRoM/EiqI1K7/nkXXjHarTy X-Received: by 2002:a25:70c1:: with SMTP id l184mr15729710ybc.87.1596787960058; Fri, 07 Aug 2020 01:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596787960; cv=none; d=google.com; s=arc-20160816; b=N4pEGDoEqcUQzz8CaUP97+PHzwPdq+KUzrtMOwTGs1TqLC6O3wAVE5xTp3msmqWVg/ 0jd3s/lWJKOtLcMSXdwL642EU0kYD8rHllp/N0Zl5u95rWosdIHDMBrvQnfVkkO61XzY O0z0i2xXu270DVl/LZ6ubItoqxSfJK6vNAX/1j2s59IbW8R8Lk0W4Y6a7VqjFrYEf0gv DtyGgmruc3lPEX1xIjzPq9XEBDY2iKib1TI8AS1ULMAL9JCyT967bTmuSydLiKb0NDfi eHYrUdpScAxvaizDmpa+85TmwDlZ+wEz5oj2cJXYc7iJp+/Gv4GyIHBxTYjH02FK5Ybh eCaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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/G09uSg2yJJtjqwnmBQeFoDjYpnvCt5OlRmmWUK0Ac=; b=AIpSjMYfPDkuoDud/nsONawWf7rubRP7VN3eYh1r0ZveQagwh7hxCQt2dEjgEqpLW/ rshQ2WsJy8FPlXiF+RnBVKaTy4Vh1HmDp+EsEEYntluAfFii0UV8f2FcoGDfRbS0rl4P zT9DZxTv+S2yizhVGWWvekIBjFNCRiOkNwC3MbzcsIum29/25CrrkpkVeVB5aX+bgoRx INx7u26TYMsDT9pNC7+qeMZyIRj1DfmLvzlxmotldd5FJUdN300hoYLn01w1SUKGg7O6 VSZ7tySwy39Ooe43vro+YXv8rd1vP0GN5sZckM246cZKetRTY+VcpzJ3jnQBrFc5gF15 U7hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tTSRJKGf; 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=fail (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 r186si7434059ybc.113.2020.08.07.01.12.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Aug 2020 01:12:40 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=tTSRJKGf; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3xUV-0000Yd-Gt for patch@linaro.org; Fri, 07 Aug 2020 04:12:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3xSg-00073T-PX for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:46 -0400 Received: from mail-io1-xd43.google.com ([2607:f8b0:4864:20::d43]:39053) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3xSd-0001hX-MH for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:46 -0400 Received: by mail-io1-xd43.google.com with SMTP id z6so1063893iow.6 for ; Fri, 07 Aug 2020 01:10:43 -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=L/G09uSg2yJJtjqwnmBQeFoDjYpnvCt5OlRmmWUK0Ac=; b=tTSRJKGfAxOBsFsSTy7WUzO2js2DVnRgl7sVSHksknJ19BC/jkJYUodydEAAVkKYWZ qGaXvRoMm48WvYyGkCkfdBKN2MdKuk0XEa/SshlYAlzNljcrnmRIBG34Hh8WFlvLx6TS Z3pv+08BliwfJsSVGwTigJT+CF4wDpCbUAXDWr1BS2ehv1AmPa8JZFSCBYKCe4qvdoRk qfgqzNE2R8N99gXJp4XozOKp/FSmRjTunknJ4893vkgjdm8iyX7dFCwv4ACNyEMcU4Rb dX3aAiGjK7TOBsP+NCLmaB8KC2DTHa6OddcoqaC9NpOaeADYQae/LmwK2M1ygl4gvZGS oMYg== 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=L/G09uSg2yJJtjqwnmBQeFoDjYpnvCt5OlRmmWUK0Ac=; b=rndKWEOugFupsW1KXzKongMN5u6XSXIGwXutvoA/jt+sOUWYPzCRlNY5Vb5uMqCg+v PxSQY2zCH+jh5spEAfnkcVw/JTzaCeIl6ttumR8tg3IGkpZ+p6ZW9shYyOnn25ngSOws 8YczPIgzsKt+/FbMYm3OGO3H2QNnSX0+tPSK+OllKKNYRUPAUtZzxm+kg4qmYSM0Q/fF txi1zefPwodfB3HEJLbCpcxKy5/l874AXM/IecRDa9qliF48r93vBFJrtFjTfq4mbL2K xSiWS1ceH60C3motE5nMtWG4d3mUaKrIAKAPNto17wXQyrS7bzqPEFusKkBTMJfg3Vmc kq1g== X-Gm-Message-State: AOAM532glkTIUVZ0rk4gFzzSxWwDrIO5XUKIayECWWbBWsDLN/xMMFBz AU/Td6PXPMJFdQRkn3CuAjWO X-Received: by 2002:a5e:d519:: with SMTP id e25mr3334981iom.36.1596787842680; Fri, 07 Aug 2020 01:10:42 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id l144sm6233546ill.6.2020.08.07.01.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 01:10:42 -0700 (PDT) From: Haibo Xu To: peter.maydell@linaro.org Subject: [PATCH 3/7] target/arm/cpu: spe: Add an option to turn on/off vSPE support Date: Fri, 7 Aug 2020 08:10:33 +0000 Message-Id: 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::d43; envelope-from=haibo.xu@linaro.org; helo=mail-io1-xd43.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: drjones@redhat.com, qemu-arm@nongnu.org, philmd@redhat.com, qemu-devel@nongnu.org, Haibo Xu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Adds a spe=[on/off] option to enable/disable vSPE support in guest vCPU. Note this option is only available for "-cpu host" with KVM mode, and default value is on. Signed-off-by: Haibo Xu --- target/arm/cpu.c | 28 ++++++++++++++++++++++++++++ target/arm/cpu.h | 3 +++ 2 files changed, 31 insertions(+) -- 2.17.1 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 111579554f..40768b4d19 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1122,6 +1122,29 @@ static void arm_set_pmu(Object *obj, bool value, Error **errp) cpu->has_pmu = value; } +static bool arm_get_spe(Object *obj, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + + return cpu->has_spe; +} + +static void arm_set_spe(Object *obj, bool value, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + + if (value) { + if (kvm_enabled() && !kvm_arm_spe_supported()) { + error_setg(errp, "'spe' feature not supported by KVM on this host"); + return; + } + set_feature(&cpu->env, ARM_FEATURE_SPE); + } else { + unset_feature(&cpu->env, ARM_FEATURE_SPE); + } + cpu->has_spe = value; +} + unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) { /* @@ -1195,6 +1218,11 @@ void arm_cpu_post_init(Object *obj) object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu); } + if (arm_feature(&cpu->env, ARM_FEATURE_SPE)) { + cpu->has_spe = true; + object_property_add_bool(obj, "spe", arm_get_spe, arm_set_spe); + } + /* * Allow user to turn off VFP and Neon support, but only for TCG -- * KVM does not currently allow us to lie to the guest about its diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9e8ed423ea..fe0ac14386 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -822,6 +822,8 @@ struct ARMCPU { bool has_el3; /* CPU has PMU (Performance Monitor Unit) */ bool has_pmu; + /* CPU has SPE (Statistical Profiling Extension) */ + bool has_spe; /* CPU has VFP */ bool has_vfp; /* CPU has Neon */ @@ -1959,6 +1961,7 @@ enum arm_features { ARM_FEATURE_VBAR, /* has cp15 VBAR */ ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ ARM_FEATURE_M_MAIN, /* M profile Main Extension */ + ARM_FEATURE_SPE, /* has SPE support */ }; static inline int arm_feature(CPUARMState *env, int feature) From patchwork Fri Aug 7 08:10:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 247539 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2232721ilo; Fri, 7 Aug 2020 01:12:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWbju2AxX2TL0luSwWv38qYHuhwS8oh0bMweLpWTTOMJ9sf5XU/7qQP+g8CNCv8bBFMWdh X-Received: by 2002:a25:5707:: with SMTP id l7mr17293046ybb.49.1596787949363; Fri, 07 Aug 2020 01:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596787949; cv=none; d=google.com; s=arc-20160816; b=LTiowsN43t1n8eh+KMiAI16+lr8Y5GSFYlROqiKYt88qvgZfAELKPcofXxiscRO4UE hfRANQHYcCDf/C1qBQhYWurGB1fRZhtypu2E21mn/8oj4H2inUx4nX9Yj/x7CwlfBems Wb/j7KDDaj12EltSUttvo007zc9bzv/hs8muzrmv7e/pyxypmi0kW9+crEzZ3flisO9J Zv1cG3gvhIEBl1cRiiLR1ouJ8tYuMysG49bG45Rj2YfMRyl23RbCE+DVtDClINihO0sA yAJuCgib0i1RuhOpxFc17A9LQd0as9dZR1Cnmo35TN3wmE47KotjUx//PtG1kyQMfKaY ncpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=FLxPSbNc8qBJd2uwAUxDf5Aqk4UdZ/EXxQhhbBHEloc=; b=Utv4TX6QsH0lXegUm83qsofEAi9VUADONE5rrQ1CprV3z2/CmBQGSxrKA18EWszGUL d3DZvXxcZlx/ydoYaHTzC6a19+LEWHaNp3byazP0TzQ9L5EbMfPwdDKMRpmNxZ42h2or +EHuI/bT60jqDO1BJ4iw4BmKtCv26W9t24UfD88cztjlYXBGMT2Jg58ZwVuv1GXZNAAu kpxW1vHXK4fXyDL7Rrjp+jxljR1nyhYOW066MwUl9oSy7SBR+MKkEMtineSAWQaWm+72 4LlKeNl/50Iiuvvu+G4/lIW24D0Eh6M9GNbmTYXXBfHxyL3FtrsYvdiutMPlJin3AQv3 V4Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vN+axuX0; 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=fail (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 o11si7311641ybm.201.2020.08.07.01.12.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Aug 2020 01:12:29 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=vN+axuX0; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3xUK-0001Br-Pl for patch@linaro.org; Fri, 07 Aug 2020 04:12:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3xSh-00075y-Uc for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:47 -0400 Received: from mail-il1-x142.google.com ([2607:f8b0:4864:20::142]:36870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3xSf-0001hr-5S for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:47 -0400 Received: by mail-il1-x142.google.com with SMTP id p13so1095983ilh.4 for ; Fri, 07 Aug 2020 01:10:44 -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=FLxPSbNc8qBJd2uwAUxDf5Aqk4UdZ/EXxQhhbBHEloc=; b=vN+axuX0BiTVzrwJlPuTKVpTIsoUkb0OKxnRR0zclCIJ3Z/zZaU4og1CbUjcn5i5rg VhwXXsZASc0IBmkoeV04nKjHmKBl5cZwCm2pAeAIZU6gS1Q8JdScWa3yuI28/Mdqe5Pq hWblHShKWYdgYQSWOgxQOyAoeRy7AtDr+bzfVrgr0WxLryNaTrdM5vBZmWh+HoZxAspn zTF/FUUWrKjfAMWeCSVRL3RmBEchDFL5Ksfy5kxGJuX4JpXzv+4LYliEx6ww4tHLrkT3 3U7+j6muzUzE51EwN+9VukgVSEKNBVLpzDPRfdO49m1CfaYhllpGHco8yGiVhYkd5fTp H2pA== 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=FLxPSbNc8qBJd2uwAUxDf5Aqk4UdZ/EXxQhhbBHEloc=; b=sRuiFs0j98fNMuvurfWnBxlcOTeq0rgWPtS3xZ0l8yLpm6vxEf+jBqndc6Ui5qawQY CPeeG0UZ9Hrgh+eWGEJIuox6zXEQlRwJCrChoPmqWqrJbJunM3KEA4bvTxACk50Zz45S tfDLOz1NKe+SSalxByLo+CUCH+Uo3yZGWpfpnrF9Y84JrnPhnfEMPjYJ1k3lYY3Cx3iK GIRhZy+dZoi/707B1dy9E0IjUm28fFLXdBrE+CgEfHeeXm69e+YY8kXOKC1m+Bu0bicq Cj/rP4UtBWq62OzJ9dqkk8CRtexBfr27LzoobAHm15+XcT0AkVvSs247SNL0WlE9kPjB YVTg== X-Gm-Message-State: AOAM530ahXFdo6FPOMZOGz+FjQk/CVJ9Em6bW3RUKMnLRG4RnpgTZnkA DHgbLdi0kRBmk1pzjvm6Z1Q6 X-Received: by 2002:a92:d60b:: with SMTP id w11mr2984880ilm.156.1596787844021; Fri, 07 Aug 2020 01:10:44 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id l144sm6233546ill.6.2020.08.07.01.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 01:10:43 -0700 (PDT) From: Haibo Xu To: peter.maydell@linaro.org Subject: [PATCH 4/7] target/arm/kvm: spe: Unify device attr operatioin helper Date: Fri, 7 Aug 2020 08:10:34 +0000 Message-Id: <3cc31df5191ae6b03e060ccd8e82df74416a3ef5.1596768588.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::142; envelope-from=haibo.xu@linaro.org; helo=mail-il1-x142.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: drjones@redhat.com, qemu-arm@nongnu.org, philmd@redhat.com, qemu-devel@nongnu.org, Haibo Xu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rename kvm_arm_pmu_set_attr() to kvm_arm_dev_set_attr(), So both the vPMU and vSPE device can share the same API. Signed-off-by: Haibo Xu --- target/arm/kvm64.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 1169237905..75a417d65c 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -398,7 +398,7 @@ static CPUWatchpoint *find_hw_watchpoint(CPUState *cpu, target_ulong addr) return NULL; } -static bool kvm_arm_pmu_set_attr(CPUState *cs, struct kvm_device_attr *attr) +static bool kvm_arm_dev_set_attr(CPUState *cs, struct kvm_device_attr *attr) { int err; @@ -427,7 +427,7 @@ void kvm_arm_pmu_init(CPUState *cs) if (!ARM_CPU(cs)->has_pmu) { return; } - if (!kvm_arm_pmu_set_attr(cs, &attr)) { + if (!kvm_arm_dev_set_attr(cs, &attr)) { error_report("failed to init PMU"); abort(); } @@ -444,7 +444,7 @@ void kvm_arm_pmu_set_irq(CPUState *cs, int irq) if (!ARM_CPU(cs)->has_pmu) { return; } - if (!kvm_arm_pmu_set_attr(cs, &attr)) { + if (!kvm_arm_dev_set_attr(cs, &attr)) { error_report("failed to set irq for PMU"); abort(); } From patchwork Fri Aug 7 08:10:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 247541 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2233033ilo; Fri, 7 Aug 2020 01:13:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCkN0jLuGoTHUdqOryIQV/ytJtLV23a9dGQztRaZ9pS8peEdYJtHo4PgiI0dLFmLFjMcRr X-Received: by 2002:a5b:c08:: with SMTP id f8mr17569865ybq.198.1596787985153; Fri, 07 Aug 2020 01:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596787985; cv=none; d=google.com; s=arc-20160816; b=qroEJiWacjrFwcybe5nISX2ihf6kl5E5KOupsl4ZYYpjWRVw6NXTkK3IDfPXUZQlFq 0seS0q+EZUPLspZndYWsRpnm+UFZHM9ZZ1RUoSYjpevbhH4GQWwdRxzEKZghoHfAhOjP MV6N4xII7fCYNbtzizVVIWJjuAvARU5440wuxQ94BssPdUs+34hTZOnQH0MB4MkEgwVN N6KUIiSkvldtfPFV5fyK7WKpLL23lCW9p0SrwrQ2ZVp05WvGMrbnURzgvK5HZ4+enU7f kOkRZVyDKEzfB4hK+vKJUWCvYNoJ5c/OH1tVxswQ21CF1lcUAugcsUr2eAtu2uwkhM+M Bfbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=E4Z1kCiUrBimgEjKsiAAuWvSYrgx0uM3+pFLTYp+Tfo=; b=kdiXsOcv+AZYCAvjh05ySLSjZE8QiOwG0NyB+i4PUpEjTSR+nfGlB/TYBNYz5SCuUf fnjqeo36tWtAZGVvhDurC2VjCy2mMznhwySS14zTSzheCzpn3O7BcfzsFjyuh0BTH3xj IkJp2F4As9IUVgLStupxPBES4IUA2H3Q9R075yjl1u/cfuC+PFjeICIJ0Nsz7O7qTROf Xo6f2tisw2W08G+/8QfoZABCqX4VxtarA8rYRsYYn9d0N+hree2G0Nq/nXfOmraZv2sX ecoAqfq2p8PuJS9LDpMHBR+zvQMznkhLyPwiou78ZvAFSU4ULM9FlgfTA8Vab/fdaX83 g3sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="cJ/kFwfh"; 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=fail (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 q4si6462218ybo.416.2020.08.07.01.13.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Aug 2020 01:13:05 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b="cJ/kFwfh"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3xUu-0002fR-Ic for patch@linaro.org; Fri, 07 Aug 2020 04:13:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3xSi-00077u-EJ for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:48 -0400 Received: from mail-il1-x142.google.com ([2607:f8b0:4864:20::142]:46971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3xSf-0001i5-Qe for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:48 -0400 Received: by mail-il1-x142.google.com with SMTP id c6so1053809ilo.13 for ; Fri, 07 Aug 2020 01:10:45 -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=E4Z1kCiUrBimgEjKsiAAuWvSYrgx0uM3+pFLTYp+Tfo=; b=cJ/kFwfhn0FpSeVU1gWECY0BMOHuLuuuFwU84PSbXIGANz1yeQ6pVm/aNOrqlW3l4d kdb+Fnx3KFnZgwbFN9kJ0cmu4dde0Zf0PuydYkpx+mca88+DoEDbWpEmCaqXLQYGx2vL x5MWt2JB4xazsZlIpjkeQc/McsUDBrfiJaAmOLda7mPwls1in12KEm6hG/lErHNrO1DB VT3EikXKtjMEn/rGn8Ff4gEEVYWFjMsFsDkAkp1A+7SsaCdOmicD3N0UTdi+gVXSYZSM MVvL8ZgiVNjoFZf4FbdYJNUVwYi6fivUJ0BQ35/3iw+vnl2kJhG23rZeA9egmbDq9+23 7vFg== 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=E4Z1kCiUrBimgEjKsiAAuWvSYrgx0uM3+pFLTYp+Tfo=; b=Ogawfm3SMcHfjoTlKTuSrYTSdaMIVWd1hMBSW3J0PINUXDmNgIW/Nw1dMdwEhPEfh4 siw+PuBvHdNhFqwd7GtHYxI9haCD7EyTudlwU47ONBFiN8KdkYeiUiAVPfMhtYMYWdBC KcpjSRRPZ8WYCCOdAZ+noNQuw5RjcuMjajKMZzRVdLAojaOUhifZBgzkCTf19f1eeCp6 vmXawTiRIW8W6Ez4/2CsVIEhPPrqaA5cPBREujngOdf2X1IUeSGeMUvSM3YZbIwkJ/xx ST1uxNDhTQcDsX0s04EViuPgHMUBz/R5Q3XDoQkvT20UwGx7ORSbuX0DWnmCqdrkwLKg SNuw== X-Gm-Message-State: AOAM532I2AvN5x76TQtubQ3YP3CvtSlX/iYMy0A6eRkSAjSL4i2atDFG 2YT93P41k07ZZmmbAdmf5/Fe X-Received: by 2002:a92:cb07:: with SMTP id s7mr3206988ilo.58.1596787844820; Fri, 07 Aug 2020 01:10:44 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id l144sm6233546ill.6.2020.08.07.01.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 01:10:44 -0700 (PDT) From: Haibo Xu To: peter.maydell@linaro.org Subject: [PATCH 5/7] target/arm/kvm: spe: Add device init and set_irq operations Date: Fri, 7 Aug 2020 08:10:35 +0000 Message-Id: <3160507b3f981c92857d3234468d3de1dd352a03.1596768588.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::142; envelope-from=haibo.xu@linaro.org; helo=mail-il1-x142.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: drjones@redhat.com, qemu-arm@nongnu.org, philmd@redhat.com, qemu-devel@nongnu.org, Haibo Xu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Haibo Xu --- target/arm/kvm64.c | 33 +++++++++++++++++++++++++++++++++ target/arm/kvm_arm.h | 5 +++++ 2 files changed, 38 insertions(+) -- 2.17.1 diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 75a417d65c..be045ccc5f 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -450,6 +450,39 @@ void kvm_arm_pmu_set_irq(CPUState *cs, int irq) } } +void kvm_arm_spe_init(CPUState *cs) +{ + struct kvm_device_attr attr = { + .group = KVM_ARM_VCPU_SPE_V1_CTRL, + .attr = KVM_ARM_VCPU_SPE_V1_INIT, + }; + + if (!ARM_CPU(cs)->has_spe) { + return; + } + if (!kvm_arm_dev_set_attr(cs, &attr)) { + error_report("failed to init SPE"); + abort(); + } +} + +void kvm_arm_spe_set_irq(CPUState *cs, int irq) +{ + struct kvm_device_attr attr = { + .group = KVM_ARM_VCPU_SPE_V1_CTRL, + .addr = (intptr_t)&irq, + .attr = KVM_ARM_VCPU_SPE_V1_IRQ, + }; + + if (!ARM_CPU(cs)->has_spe) { + return; + } + if (!kvm_arm_dev_set_attr(cs, &attr)) { + error_report("failed to set irq for SPE"); + abort(); + } +} + static int read_sys_reg32(int fd, uint32_t *pret, uint64_t id) { uint64_t ret; diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index f79655674e..bb155322eb 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -348,6 +348,8 @@ int kvm_arm_vgic_probe(void); void kvm_arm_pmu_set_irq(CPUState *cs, int irq); void kvm_arm_pmu_init(CPUState *cs); +void kvm_arm_spe_set_irq(CPUState *cs, int irq); +void kvm_arm_spe_init(CPUState *cs); int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level); #else @@ -397,6 +399,9 @@ static inline int kvm_arm_vgic_probe(void) static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {} static inline void kvm_arm_pmu_init(CPUState *cs) {} +static inline void kvm_arm_spe_set_irq(CPUState *cs, int irq) {} +static inline void kvm_arm_spe_init(CPUState *cs) {} + static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) {} static inline void kvm_arm_get_virtual_time(CPUState *cs) {} From patchwork Fri Aug 7 08:10:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 247544 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2234043ilo; Fri, 7 Aug 2020 01:14:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEpDcAmp9O2NDUVvW6j2zoLMWlpYDMD0RrfbjWMwCepVpxQbnFzHFn8EY6Et0ZyQlcf2V7 X-Received: by 2002:a05:6902:1022:: with SMTP id x2mr18748525ybt.391.1596788099834; Fri, 07 Aug 2020 01:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596788099; cv=none; d=google.com; s=arc-20160816; b=AQymbMM3rdUyo40mJQeF98UL2dpGKphA+W765slLNvMglt+XuTbiaR9qlbA1HrW4rM m/I47vb91wXJZQmhxbBVZwZUIEk+SxKFjLFceQmYg9qO+qlFShxt1/YtTO77tsYiBf0X kqXsFLW06lCeWAQyMYzNhymunEuw6rhiI7xKvrQVCPefnJwsUL9NkbQH/LTEDKirs6Qn NnlpV/ruUHrPaTMwzuj9lXLhdewRt5V/AGM1zox1haUCIKTY8zIVjuW+YnUTZX9fpBhy 0mMGO+zRqQR19lsVpZSCKLzFhuYk36JtTWJvmk2VPhkkxmvU9WL79lLLJULWa9jHTXj0 qIWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=k9EtU7qoqqVliH9xoeZ1LmKv9XpHBnu6eM6bbX8j8B0=; b=IEx8T38cd2eU9QqCoaIYA1sDrzW4EQhuGqPmSjaGiqwg03qQjnsoqK/qrnm/ubElA5 ewvVYj8IrbiKM5ewjjia9iM4/qCvOmUblcud04R9wSw91yVYzc8svFM0A+e9KYQZiaUL seCsTM48ykde7VDZZE5YSJCuNgjxaYiHpJfCQ5VzsGQJHRu06xLHQPrUYWlGaOXgrYOT 2OVOCI1tzvO0RgAKH1EAvOLMcH3zhRGzC+1jIis/Jy2DsnOJPwTWueqLpS4Tzi3Z3vpA 8CFBZwC89LYkZ41moEpRs95zjgIst09MmzNuwLTV2EWIf9i0o4JuITlKZvbMq+ooOCt5 HJBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VzMK4AMM; 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=fail (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 a10si8553124ybi.117.2020.08.07.01.14.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Aug 2020 01:14:59 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=VzMK4AMM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3xWl-0005T3-1P for patch@linaro.org; Fri, 07 Aug 2020 04:14:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3xSj-0007Ai-H7 for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:49 -0400 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]:41474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3xSh-0001iK-1n for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:49 -0400 Received: by mail-io1-xd41.google.com with SMTP id g19so1058142ioh.8 for ; Fri, 07 Aug 2020 01:10:46 -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=k9EtU7qoqqVliH9xoeZ1LmKv9XpHBnu6eM6bbX8j8B0=; b=VzMK4AMM03CD6piAtOty8shk2rqBueFuMKbQMQ5SH894nDPFSk29lmXvw14m2EaCBQ p3A3IlZVIpoHzA8alas/XC9te0eWHhxGv2KYtmrjBVJocsoh9O1x6vgmS9IvWY62Sl2a dCILYQce5J+E5OqrpyUbpcjoyJH+xDm+qV+bG/DZqIpIV1v11z2jUNmF8N+89HP312rh x6ikRBz/KFI848NbF2SMzthMbrrLm9sEHGRBfsQsMBkT/BxjgGNwO6Q1BEn7xWB5qQOA 0xMO/UOLzSH+9N9zsAQAQ7a6gbmU7SLwsAIvxBLTou8YihLCQsfL5m4NisFiYpT+tcDF h2tw== 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=k9EtU7qoqqVliH9xoeZ1LmKv9XpHBnu6eM6bbX8j8B0=; b=bjuiq5YhpXYXjGIqsYfktIiBxuIvIoJ3yqS6kJd+MPydh5OKCdoLofVCg2dpOZ6/eS UDHq90QahArjoBrKtTcZUoyrCjnlC/H57k4JH2VO5NNeq3L7EsosjrrohAwvqiInH9gU sjN8dUMnq/+O6UkPXpz+OuR2Mk2nonlMvX/gtlVZc0pIvx1UQPAl/yeMlrEkKjcw+r2e JWtYDM0MNzYTmvtFqNrWw6CNNOzG0e//86EHbGIRZFkI1zYPHruCMOOGgLMx8UIHvD+o pZg/9hZc0ZLhbNT9W1zxJOZdRSW/DIvYX7xSRmBU9JyPGOmJ+iohnwGqzwJB2ytgEwSy 4sog== X-Gm-Message-State: AOAM533s+Z3Lb71Saa4+vI2phJnBvTi64ptGAoEELhl0Go4UkfBDcHWm 6oVv7Usdfct9ofH0ajP+lhxr18cVOSqNxh4= X-Received: by 2002:a5e:dd02:: with SMTP id t2mr3158305iop.90.1596787845770; Fri, 07 Aug 2020 01:10:45 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id l144sm6233546ill.6.2020.08.07.01.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 01:10:45 -0700 (PDT) From: Haibo Xu To: peter.maydell@linaro.org Subject: [PATCH 6/7] hw/arm/virt: spe: Add SPE fdt binding for virt machine Date: Fri, 7 Aug 2020 08:10:36 +0000 Message-Id: <1663d06172cffa723e00893837ba04634f061fc8.1596768588.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::d41; envelope-from=haibo.xu@linaro.org; helo=mail-io1-xd41.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: drjones@redhat.com, qemu-arm@nongnu.org, philmd@redhat.com, qemu-devel@nongnu.org, Haibo Xu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add a virtual SPE device for virt machine while using PPI 5 for SPE overflow interrupt number. Signed-off-by: Haibo Xu --- hw/arm/virt-acpi-build.c | 3 +++ hw/arm/virt.c | 42 +++++++++++++++++++++++++++++++++++++ include/hw/acpi/acpi-defs.h | 1 + include/hw/arm/virt.h | 1 + target/arm/cpu.c | 2 ++ target/arm/cpu.h | 2 ++ target/arm/kvm.c | 6 ++++++ 7 files changed, 57 insertions(+) -- 2.17.1 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 91f0df7b13..5073ba22a5 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -666,6 +666,9 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) if (arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { gicc->performance_interrupt = cpu_to_le32(PPI(VIRTUAL_PMU_IRQ)); } + if (arm_feature(&armcpu->env, ARM_FEATURE_SPE)) { + gicc->spe_interrupt = cpu_to_le32(PPI(VIRTUAL_SPE_IRQ)); + } if (vms->virt) { gicc->vgic_interrupt = cpu_to_le32(PPI(ARCH_GIC_MAINT_IRQ)); } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ecfee362a1..c40819705d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -555,6 +555,42 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) } } +static void fdt_add_spe_nodes(const VirtMachineState *vms) +{ + CPUState *cpu; + ARMCPU *armcpu; + uint32_t irqflags = GIC_FDT_IRQ_FLAGS_LEVEL_HI; + + CPU_FOREACH(cpu) { + armcpu = ARM_CPU(cpu); + if (!arm_feature(&armcpu->env, ARM_FEATURE_SPE)) { + return; + } + if (kvm_enabled()) { + if (kvm_irqchip_in_kernel()) { + kvm_arm_spe_set_irq(cpu, PPI(VIRTUAL_SPE_IRQ)); + } + kvm_arm_spe_init(cpu); + } + } + + if (vms->gic_version == VIRT_GIC_VERSION_2) { + irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START, + GIC_FDT_IRQ_PPI_CPU_WIDTH, + (1 << vms->smp_cpus) - 1); + } + + armcpu = ARM_CPU(qemu_get_cpu(0)); + qemu_fdt_add_subnode(vms->fdt, "/spe"); + if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) { + const char compat[] = "arm,statistical-profiling-extension-v1"; + qemu_fdt_setprop(vms->fdt, "/spe", "compatible", + compat, sizeof(compat)); + qemu_fdt_setprop_cells(vms->fdt, "/spe", "interrupts", + GIC_FDT_IRQ_TYPE_PPI, VIRTUAL_SPE_IRQ, irqflags); + } +} + static inline DeviceState *create_acpi_ged(VirtMachineState *vms) { DeviceState *dev; @@ -727,6 +763,10 @@ static void create_gic(VirtMachineState *vms) qdev_get_gpio_in(vms->gic, ppibase + VIRTUAL_PMU_IRQ)); + qdev_connect_gpio_out_named(cpudev, "spe-interrupt", 0, + qdev_get_gpio_in(vms->gic, ppibase + + VIRTUAL_SPE_IRQ)); + sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); sysbus_connect_irq(gicbusdev, i + smp_cpus, qdev_get_gpio_in(cpudev, ARM_CPU_FIQ)); @@ -1915,6 +1955,8 @@ static void machvirt_init(MachineState *machine) fdt_add_pmu_nodes(vms); + fdt_add_spe_nodes(vms); + create_uart(vms, VIRT_UART, sysmem, serial_hd(0)); if (vms->secure) { diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 38a42f409a..56a7f38ae4 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -302,6 +302,7 @@ struct AcpiMadtGenericCpuInterface { uint32_t vgic_interrupt; uint64_t gicr_base_address; uint64_t arm_mpidr; + uint16_t spe_interrupt; /* ACPI 6.3 */ } QEMU_PACKED; typedef struct AcpiMadtGenericCpuInterface AcpiMadtGenericCpuInterface; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index dff67e1bef..56c83224d2 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -49,6 +49,7 @@ #define ARCH_TIMER_NS_EL1_IRQ 14 #define ARCH_TIMER_NS_EL2_IRQ 10 +#define VIRTUAL_SPE_IRQ 5 #define VIRTUAL_PMU_IRQ 7 #define PPI(irq) ((irq) + 16) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 40768b4d19..67ab0089fd 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1038,6 +1038,8 @@ static void arm_cpu_initfn(Object *obj) "gicv3-maintenance-interrupt", 1); qdev_init_gpio_out_named(DEVICE(cpu), &cpu->pmu_interrupt, "pmu-interrupt", 1); + qdev_init_gpio_out_named(DEVICE(cpu), &cpu->spe_interrupt, + "spe-interrupt", 1); #endif /* DTB consumers generally don't in fact care what the 'compatible' diff --git a/target/arm/cpu.h b/target/arm/cpu.h index fe0ac14386..4bf8591df8 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -790,6 +790,8 @@ struct ARMCPU { qemu_irq gicv3_maintenance_interrupt; /* GPIO output for the PMU interrupt */ qemu_irq pmu_interrupt; + /* GPIO output for the SPE interrupt */ + qemu_irq spe_interrupt; /* MemoryRegion to use for secure physical accesses */ MemoryRegion *secure_memory; diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 58f991e890..ecafdda364 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -820,6 +820,12 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) switched_level &= ~KVM_ARM_DEV_PMU; } + if (switched_level & KVM_ARM_DEV_SPE) { + qemu_set_irq(cpu->spe_interrupt, + !!(run->s.regs.device_irq_level & KVM_ARM_DEV_SPE)); + switched_level &= ~KVM_ARM_DEV_SPE; + } + if (switched_level) { qemu_log_mask(LOG_UNIMP, "%s: unhandled in-kernel device IRQ %x\n", __func__, switched_level); From patchwork Fri Aug 7 08:10:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 247543 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2233958ilo; Fri, 7 Aug 2020 01:14:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI0upvNacH/wgbxYMbahE7VaSFIfiaXIjEKlwOrw5V8eb60gpJDVKGZtW1au6xkMihvtNu X-Received: by 2002:a25:cc46:: with SMTP id l67mr18183349ybf.283.1596788091797; Fri, 07 Aug 2020 01:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596788091; cv=none; d=google.com; s=arc-20160816; b=X8J3VoO9YCULFMsEefKG092/2DRd/2G13kfhjlB7auOvJm0Igx6/ZBfo0zgACBi6bB MsTvQaAnmOySNyFKkNf83WR118++14SzmL11I3YTK84k5zsd7l/6jxuCBkJzbQvaD6Ed FQTsHmLFto2PZ4dKSMV97OE3nDSMHY1DCKzmJUpdbhNZTiz/GrxR39WyEj2NAe61b+un D2Ns9c/TMpOfUxFuuExvotMzKsFAJMg9Wdh5awqWXpXgFnQAEz+/4SJrg3kX/0VynQRV qtvPwHnvh0Jyu1iR80iDascXDieHDlrMQ49qGf8glW68jnWLnVoILsdvxCdyRgKHjGZy obzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=TviGzmtVooeSyONCBmDeM4dNkoolotdPP8RSZaeKQ7o=; b=XOAzJldVmaFnLtxN/6mcjEW5OvHbu9U0nl4cjRu2Ppx0Saq+U6IxGtUfZTt2dw8eLP lWDox4s07djIatfuMu2uhgthWGfZKTCySchH8GIeyr97MfdS3A9SfQq81hm08l2Vw1ZT H6nrEXrOy66dsGKMH+S7JFrcqYhnApxy9xkAgM9S6P9Si0x9xlkt61Jze3ubYTE8sKTO Y8sRgKX5MhGg1VkHy8Rnr2DMZJzTYdW3Litfcky4mpZvuj5seQpbP9iLaeK0amio/3ly e3j+/E0UaqYDzmJ8K1xoXVZ3EoWg/im4ynPXNCxKlOupmuinBPx1Xu5IE0iupuu/fYMw Mu0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NnLuiKB3; 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=fail (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 a18si7349433ybs.331.2020.08.07.01.14.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Aug 2020 01:14:51 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=NnLuiKB3; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3xWd-00069u-7z for patch@linaro.org; Fri, 07 Aug 2020 04:14:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3xSk-0007CZ-1f for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:50 -0400 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]:38654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3xSh-0001iZ-L5 for qemu-devel@nongnu.org; Fri, 07 Aug 2020 04:10:49 -0400 Received: by mail-io1-xd44.google.com with SMTP id l1so1073662ioh.5 for ; Fri, 07 Aug 2020 01:10:47 -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=TviGzmtVooeSyONCBmDeM4dNkoolotdPP8RSZaeKQ7o=; b=NnLuiKB3M9BBUwK6Ivp+tfr1wgrcB2dVtHLFJLK3G5M7zD8ZVcpU+F8n1mLDr+8QX7 jEwIsOVdjpwqq5wwpQbmgBnzV9U+J6n+aoT8+z3R+iedUYm8Sgrymxsb4sBNMDm46jdi OoZtB/mh1L99BGq99JUGlHhsROt4PcYEyGGaM28kH99B8T7GiszCu9tlab4pn+VW/EfL wVFSfWlHzJo3TSK+b0IRS3cnNVCydf+zItie7bCmpjvdMlXCUc0kG1YCTTKelDnkvTPS CwnX+vWK8IdqIEcz306Dj+u4Kb37g7NJQM4pOaOZPN9RXzqzisygEg1OmHGLagiH4raL 5EHQ== 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=TviGzmtVooeSyONCBmDeM4dNkoolotdPP8RSZaeKQ7o=; b=eCkeMHQlsRwK2GbhnfZ53tysBvknBhSjT3G7pULUI7ZSbTMJgYnia6/wTGs/k0/k3R JVpSvMwbZWErBNSDuf1UCZmyghZcjlk6Yh6sU9d9q8Xid/sjOZ7YeJHoPrFIDQimmVyk Ln8Lhm4kQo0SERRpn7AOc4bqy3DpSuszE/p2HVgtlObWC18hbJTvjASSdbJ1z2uBlKMz arzeg035TmcrUeJHb03jluKrWaEZY54VfJGOv02A4OTRBkjKJYFw466H0n3BNBkD7UIj f/BgP7SSqZCQVKRmjwslCdlmUI1yq1G1SQuqOP7hnrnqiu76Ddrpfi1yamMQ1sL6joq7 2gZg== X-Gm-Message-State: AOAM530Pi+KJdrh7kXo1mA4X/87WaB9EFJYxFhYG6a3qRdsH7J875zXo URnix8KlKrxTsw+NWhs34799 X-Received: by 2002:a6b:5d05:: with SMTP id r5mr3266184iob.14.1596787846498; Fri, 07 Aug 2020 01:10:46 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id l144sm6233546ill.6.2020.08.07.01.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 01:10:46 -0700 (PDT) From: Haibo Xu To: peter.maydell@linaro.org Subject: [PATCH 7/7] target/arm/cpu: spe: Enable spe to work with host cpu Date: Fri, 7 Aug 2020 08:10:37 +0000 Message-Id: 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::d44; envelope-from=haibo.xu@linaro.org; helo=mail-io1-xd44.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: drjones@redhat.com, qemu-arm@nongnu.org, philmd@redhat.com, qemu-devel@nongnu.org, Haibo Xu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Turn on the spe cpu property by default when working with host cpu type in KVM mode, i.e. we can now do '-cpu host' to add the vSPE, and '-cpu host,spe=off' to remove it. Signed-off-by: Haibo Xu --- target/arm/cpu.c | 4 ++++ target/arm/kvm64.c | 9 +++++++++ 2 files changed, 13 insertions(+) -- 2.17.1 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 67ab0089fd..42fa99953c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1719,6 +1719,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->pmceid1 = 0; } + if (!cpu->has_spe || !kvm_enabled()) { + unset_feature(env, ARM_FEATURE_SPE); + } + if (!arm_feature(env, ARM_FEATURE_EL2)) { /* Disable the hypervisor feature bits in the processor feature * registers if we don't have EL2. These are id_pfr1[15:12] and diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index be045ccc5f..4ea58afc1d 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -679,6 +679,7 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) features |= 1ULL << ARM_FEATURE_AARCH64; features |= 1ULL << ARM_FEATURE_PMU; features |= 1ULL << ARM_FEATURE_GENERIC_TIMER; + features |= 1ULL << ARM_FEATURE_SPE; ahcf->features = features; @@ -826,6 +827,14 @@ int kvm_arch_init_vcpu(CPUState *cs) } else { env->features &= ~(1ULL << ARM_FEATURE_PMU); } + if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_SPE_V1)) { + cpu->has_spe = false; + } + if (cpu->has_spe) { + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SPE_V1; + } else { + env->features &= ~(1ULL << ARM_FEATURE_SPE); + } if (cpu_isar_feature(aa64_sve, cpu)) { assert(kvm_arm_sve_supported()); cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE;