From patchwork Thu Jul 29 19:56:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12409565 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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,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 D72D9C4320A for ; Thu, 29 Jul 2021 19:59:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 AC99260F01 for ; Thu, 29 Jul 2021 19:59:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AC99260F01 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Yd242hJH42Ql6jSaEcEuY/KlH/X+EI3UjIwsdPIz3sE=; b=e4U/a9steH1rr/xH1jxYpOsmYY 3fEki8Pl+eEKYXfMNZSeTAexAQPGMIKF9udR9RqigI9cMtnhOr4xtwNX2jPkJ1xei9Z+uPILCS4U4 e0TlIQ9whc7AipEWzBvKbUIw0rNkDNRSo7YB7Qnve88x8RFGl1WfbwoEnRbqNDraHI4ncazL9snmS PR7D0frKRWWqzjsbaKogHGRJvOq9P1taUL1+16fcdHb5TSyZjtib6BWxwoUzuosrVACOz6m5Fms3P 5GVK3qB3A5Z5tHRzwFM0CSKCybej4YgnLO42Qn03AqHUM8v92Mntqrwu1/fRZ2kr5d9P/P7oSC1It qaUOBC3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9C9Q-005iGC-Sy; Thu, 29 Jul 2021 19:57:05 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9C98-005i96-81 for linux-arm-kernel@lists.infradead.org; Thu, 29 Jul 2021 19:56:47 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id t101-20020a25aaee0000b0290578c0c455b2so7797487ybi.13 for ; Thu, 29 Jul 2021 12:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pgN08b/yk00GBllZokVtpDSIFyPI7a31tDiORmsCfCE=; b=YYy23uG1UwrvJN92781dawTqDn7rZMmOuoeD+4Fa5cMOURrHKF4+7b+PbMfknbbdxA gAO0wbzpUDvMB/7yIdtwvwc5NMSXTrutcgwm4KEhR8VtONe2DahfE+BQsbia6PESTKca 0+xIPncJvhoGX1fBAjyBzaTX/3YpdeWuQTVe/qzrGc1zEJV/3vyTEgzpd5gTGq0vXQEm LeylFxvvkaMHXaRdAiuuEjB2TqJ5zZ2ew7iYg9KMiHHP25U1dRuUvOY07cskE37oe/XJ DRTHHBc88F/Vh8xcmrroJWrPOD9C13B3s6UPhD860jT69w1S70hx2aht/1RR8+d6xe5w Vv0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=pgN08b/yk00GBllZokVtpDSIFyPI7a31tDiORmsCfCE=; b=WVK8CVYzq0jvjPMTMnyk/42+3h5EEJRpcjBWHSM7S7kb54D8to1qdFQcUTnErvjJ0m AAdxXxZwaRcGVk7LRZ+9YYZOJpoKOdtjd7j7KWF1wYScUGtY0IGItSeczuTDT7aAfP7y /uAakIjyKplJRH1xU3j3hWJ+sMDB3IwB3FWIgJ8iio9FhLWejy8yJPyz7W7fYvylo9vd eFbS088/y6D3QfZk7v2LroVc5Suj51LSijbhUup7TZIHJI0GmkKf1MBFkeywl+cdOAW7 nSeo1KvaBUoeXv7Bpv1hG+BQllnNft5uJbPSCeyBs9vQm7cP6pNmteA0x+F2UTT4BFmy /mjg== X-Gm-Message-State: AOAM533KiVssGzGNoqhK0LUu/q39gL2hTZJhF8EdFq6ij3Qtn8EhwGFf G4qSGPpuAec133YDcrbbOuH+VGWQQPE= X-Google-Smtp-Source: ABdhPJxv5Q9iSjza/dtoJWD8Ji6uBJa+KRn2GwxkRTQBooW5PwZGIYhH1qvOF/ZaptJAN9C14jeegk4SH7g= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a25:7a03:: with SMTP id v3mr9033669ybc.202.1627588604139; Thu, 29 Jul 2021 12:56:44 -0700 (PDT) Date: Thu, 29 Jul 2021 19:56:30 +0000 In-Reply-To: <20210729195632.489978-1-oupton@google.com> Message-Id: <20210729195632.489978-2-oupton@google.com> Mime-Version: 1.0 References: <20210729195632.489978-1-oupton@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [PATCH 1/3] KVM: arm64: Record number of signal exits as a vCPU stat From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Thomas Gleixner , Peter Zijlstra , Andy Lutomirski , linux-arm-kernel@lists.infradead.org, Peter Shier , Shakeel Butt , Guangyu Shi , Oliver Upton , Jing Zhang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210729_125646_327050_92262304 X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Most other architectures that implement KVM record a statistic indicating the number of times a vCPU has exited due to a pending signal. Add support for that stat to arm64. Cc: Jing Zhang Signed-off-by: Oliver Upton Reviewed-by: Jing Zhang --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/guest.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 41911585ae0c..70e129f2b574 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -576,6 +576,7 @@ struct kvm_vcpu_stat { u64 wfi_exit_stat; u64 mmio_exit_user; u64 mmio_exit_kernel; + u64 signal_exits; u64 exits; }; diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index e9a2b8f27792..60d0a546d7fd 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -783,6 +783,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) if (signal_pending(current)) { ret = -EINTR; run->exit_reason = KVM_EXIT_INTR; + ++vcpu->stat.signal_exits; } /* diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 1dfb83578277..50fc16ad872f 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -50,7 +50,8 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { STATS_DESC_COUNTER(VCPU, wfi_exit_stat), STATS_DESC_COUNTER(VCPU, mmio_exit_user), STATS_DESC_COUNTER(VCPU, mmio_exit_kernel), - STATS_DESC_COUNTER(VCPU, exits) + STATS_DESC_COUNTER(VCPU, exits), + STATS_DESC_COUNTER(VCPU, signal_exits), }; static_assert(ARRAY_SIZE(kvm_vcpu_stats_desc) == sizeof(struct kvm_vcpu_stat) / sizeof(u64)); From patchwork Thu Jul 29 19:56:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12409563 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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,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 2E734C4338F for ; Thu, 29 Jul 2021 19:59:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 EF05060720 for ; Thu, 29 Jul 2021 19:59:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EF05060720 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=L5EV4LZtVZTDOGf3mqEKkYmM7v65a0jeDFWiIwMoGnM=; b=v1+mkbx5eUEOH77INtW0vehjAP 8QJSs5xQtbrZPFPGoh4tLVtADq/o3b15O2vTLUSjSqRsNnWSIbxp94iJ3FnIGg65kZV8CYLTA9CNm t7wIVsHsx3ZWyXnZWVJCS/NwzMSTJqzrnQjznxBc0rVUv+FSDpmkr6c2OcDz90nKs52TgrOvDnYR3 gKlDHp0z8UTrKq/AR4w0Zvy0JaJenMdD8EnfKvTHoK3ixA+aAxhefyTEcOxVDaseC45kCPZzqFaRB dxjdYqJDVfh4d5TayzwdfBqPTlkz7E3cE5RXnJv7LAcuroJtHcjWnibYoKn1LtSxC2R05n7tWQigk OdizFFQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9C9e-005iMG-Gc; Thu, 29 Jul 2021 19:57:18 +0000 Received: from mail-il1-x149.google.com ([2607:f8b0:4864:20::149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9C99-005i9V-8I for linux-arm-kernel@lists.infradead.org; Thu, 29 Jul 2021 19:56:48 +0000 Received: by mail-il1-x149.google.com with SMTP id y6-20020a92d0c60000b029020757e7bf9fso3828455ila.7 for ; Thu, 29 Jul 2021 12:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=OUDEC1vqPr7sdUdf2B7zr2nu10+QX6s5o8FUl8jn128=; b=m3lZXoM3uP217QVv6csbkAltS9NEEhlX5Mu2B9nMMbJPkm+CF/zpiI1uNtLlaJ3MpF XKTxlciv8MR41Pp5L7tMTygFtTj8t5ato+tsIPb5PxLea28TW9AIQvorz4AvHHqUrbg0 jl3TKtHlXkF/6dnirx+9CmRoi0oSZz7bUs5HqwZT5mfm5EptQVI1kIijkc+NydchjeGY k0xOPjTs+IS75wZoMWlION+1nkDz7PARYeuzxq5NugWy+CbXKybB1hCyzW6h9gKEWy7+ JUI3EAqUwjfTN7sgZnM5Nc3G7DjRq4i1Np6UemRK4blDB/Bfs7c1L0Ww9qGVNI4nCEqF 71mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=OUDEC1vqPr7sdUdf2B7zr2nu10+QX6s5o8FUl8jn128=; b=hPXyOWrjeIBJoxf0TOrRe38uUKClS9qM1w94u3qzKAIMRkblAoNrTwBGB+AltdM+BN oaBhKdGaxRHLY+ldeS4lS5NCN8W9VWgb4yRTZavVaAN1v3/ppPd7hh+zqkROz1lalJzv EIAhFYEYC6Sr901g836OeafRMKsK3Yg/4cxbPQ6w84am0sgw31wcVmXPvFas5wQwdpCk sBTWru5q/UvC3fLot+rWeD6/Uv+rLsyxeE/EXxSB+NyMYNbDwVZ78O9fz5WhJWKENptX Bieb9bluw7XeFWWd238AhlvJ/+VcNs2ByO4dG48U6yPD31PvdtK1SFCbq65CWzCf5tkh I1XQ== X-Gm-Message-State: AOAM530ALUZhvZRZG/AtMC4k/TkNtW40IMAkTbTezp+tTOcSO/XMFtuA HCKvaibdx0O27kT4PsCsHdzB2z78vLM= X-Google-Smtp-Source: ABdhPJwrrRQSELpkKclDmiXvKjRHCNyfC/t/jEaDJIBbOW61CMAAggTennP0JRqnhAKMtQYKP8Wl+xwYsLI= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6638:2416:: with SMTP id z22mr5873473jat.57.1627588605328; Thu, 29 Jul 2021 12:56:45 -0700 (PDT) Date: Thu, 29 Jul 2021 19:56:31 +0000 In-Reply-To: <20210729195632.489978-1-oupton@google.com> Message-Id: <20210729195632.489978-3-oupton@google.com> Mime-Version: 1.0 References: <20210729195632.489978-1-oupton@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [PATCH 2/3] entry: KVM: Allow use of generic KVM entry w/o full generic support From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Thomas Gleixner , Peter Zijlstra , Andy Lutomirski , linux-arm-kernel@lists.infradead.org, Peter Shier , Shakeel Butt , Guangyu Shi , Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210729_125647_325057_42E61D36 X-CRM114-Status: GOOD ( 11.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some architectures (e.g. arm64) have yet to adopt the generic entry infrastructure. Despite that, it would be nice to use some common plumbing for guest entry/exit handling. For example, KVM/arm64 currently does not handle TIF_NOTIFY_PENDING correctly. Allow use of only the generic KVM entry code by tightening up the include list. No functional change intended. Signed-off-by: Oliver Upton --- include/linux/entry-kvm.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/entry-kvm.h b/include/linux/entry-kvm.h index 136b8d97d8c0..0d7865a0731c 100644 --- a/include/linux/entry-kvm.h +++ b/include/linux/entry-kvm.h @@ -2,7 +2,11 @@ #ifndef __LINUX_ENTRYKVM_H #define __LINUX_ENTRYKVM_H -#include +#include +#include +#include +#include +#include #include /* Transfer to guest mode work */ From patchwork Thu Jul 29 19:56:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12409567 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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 52F11C4338F for ; Thu, 29 Jul 2021 19:59:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 1DE8C60ED4 for ; Thu, 29 Jul 2021 19:59:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1DE8C60ED4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=TP5qGdwVNm80drSy0ZegD6kaYqWhVLIZKXXDVu4tmdE=; b=ITJYdP2rBMB4c3NdV89TXLt3Db YB/QVMuP6q+cDdpRdROixs3lTV6hNHJJpXXJeTuO13T2tVEXycSgXaO+jZNoMyxX8QW+q5hh/iF1J ze3D+Y0OWJaqPGlKxETJbxHWOTKTYcY+9zyw3/xe5q0RbPBXNJ7t+lsNTp1DGW5ZGhEIeATKY/lQY GQptYilOYWFPOTANBUbrjBTbyXjrEI/0Q6sPLuBGByn8TyMzE9tAWwGLj254d/shUX/fk5avhVSQo tNSLP9MRxDjFeiOWUbjh4wmsA2l/qk8Rd2MN6TyWfMy79Ol1C/L3+Y9uaul/pl/8socPJ+2CcHj7B 9mX5bwfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9C9v-005iR9-Hv; Thu, 29 Jul 2021 19:57:35 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9C99-005iA3-U8 for linux-arm-kernel@lists.infradead.org; Thu, 29 Jul 2021 19:56:49 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id p71-20020a25424a0000b029056092741626so7767394yba.19 for ; Thu, 29 Jul 2021 12:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Ol+FzPmhNMEWcf/ywMIJRhViVzXRwXAQpsvgYkKHWL8=; b=tE4wkeBUmlcgG1Oi1kqljBqPAq2FxkSBuM/0hbXQQi2dyGcWco8yqSrmnVk4GUqTP8 B1Y6AqoRFUHY5NfwvVT//R2KLyto5BFSK3FnmrUiG6B5QJbtotKTGiSx8TAiSpUfpBX1 RwJL40P1LJTj868fIGa7CImo40MmyzVuR3Zk0Ww+Q4xy5JLKXjy5TOCJ2rrdPUPCMjd/ OHn/OlsBf1bNoxUI7q/mKah8S8j9nBSApsYGYrHhrHMJ/VdT+Cta+PFakejb4YGHGoAm Oxs/mxKqPQNfzOPDkOQwWRLi/PtiOeoWmR50Im/H2TpkCT/1DhBwEO+x3+I1HMKL+x3B WsbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Ol+FzPmhNMEWcf/ywMIJRhViVzXRwXAQpsvgYkKHWL8=; b=lXIW2rB8nyKv9cjPWQsj1ay0HNLrVZyutU538GV+CZPhaUtto7c3XpW/5h46t9zzgD 6wY24+XPgKlchvZDGZCUfIlw6PqWrkcPB0OwCD/LADVYkMIeUjFPXwjw0PnawxZDdvnq Rj3+GhWKYKmzMQEszGrJFp2fnKM3HqqpsAB0pxTZZ4DOtd+3wVrphk30azyeVAsfxpSx 28NwCVcDvmfV+DDhw2EZ6FPMnWr4MwXvij4wtESVFW2ewRDPry/AonJtL2AWvIXD/tSa omAlTGYd7BOjXmGz1y0VR7X+1pYvjvF9RiWnUgIoeNNzd96/mUxqPRixK3Vttx5c5ozR gmjw== X-Gm-Message-State: AOAM532RIWtB3SeN765Dd5K53YBU5wWApsZHO9Ya/01cLG6sSiHwMT7F EE4WXLuWvIqdYWaqWOHUOvEW811wbBI= X-Google-Smtp-Source: ABdhPJzEqeKxfCGlgZpzy/oi0hUM353MPBMR8OsyLB/q3Rn+Ob7BztAXWntKOvKujoWtbqCxSrp7KEVTT8w= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a25:55c4:: with SMTP id j187mr9110009ybb.284.1627588606437; Thu, 29 Jul 2021 12:56:46 -0700 (PDT) Date: Thu, 29 Jul 2021 19:56:32 +0000 In-Reply-To: <20210729195632.489978-1-oupton@google.com> Message-Id: <20210729195632.489978-4-oupton@google.com> Mime-Version: 1.0 References: <20210729195632.489978-1-oupton@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [PATCH 3/3] KVM: arm64: Use generic KVM xfer to guest work function From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Thomas Gleixner , Peter Zijlstra , Andy Lutomirski , linux-arm-kernel@lists.infradead.org, Peter Shier , Shakeel Butt , Guangyu Shi , Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210729_125648_018058_6CDC232B X-CRM114-Status: GOOD ( 14.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Clean up handling of checks for pending work by switching to the generic infrastructure to do so. We pick up handling for TIF_NOTIFY_RESUME from this switch, meaning that task work will be correctly handled. Signed-off-by: Oliver Upton --- arch/arm64/kvm/Kconfig | 1 + arch/arm64/kvm/arm.c | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig index a4eba0908bfa..8bc1fac5fa26 100644 --- a/arch/arm64/kvm/Kconfig +++ b/arch/arm64/kvm/Kconfig @@ -26,6 +26,7 @@ menuconfig KVM select HAVE_KVM_ARCH_TLB_FLUSH_ALL select KVM_MMIO select KVM_GENERIC_DIRTYLOG_READ_PROTECT + select KVM_XFER_TO_GUEST_WORK select SRCU select KVM_VFIO select HAVE_KVM_EVENTFD diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 60d0a546d7fd..9762e2129813 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -714,6 +715,13 @@ static bool vcpu_mode_is_bad_32bit(struct kvm_vcpu *vcpu) static_branch_unlikely(&arm64_mismatched_32bit_el0); } +static bool kvm_vcpu_exit_request(struct kvm_vcpu *vcpu) +{ + return kvm_request_pending(vcpu) || + need_new_vmid_gen(&vcpu->arch.hw_mmu->vmid) || + xfer_to_guest_mode_work_pending(); +} + /** * kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest code * @vcpu: The VCPU pointer @@ -757,7 +765,11 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) /* * Check conditions before entering the guest */ - cond_resched(); + if (__xfer_to_guest_mode_work_pending()) { + ret = xfer_to_guest_mode_handle_work(vcpu); + if (!ret) + ret = 1; + } update_vmid(&vcpu->arch.hw_mmu->vmid); @@ -776,16 +788,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) kvm_vgic_flush_hwstate(vcpu); - /* - * Exit if we have a signal pending so that we can deliver the - * signal to user space. - */ - if (signal_pending(current)) { - ret = -EINTR; - run->exit_reason = KVM_EXIT_INTR; - ++vcpu->stat.signal_exits; - } - /* * If we're using a userspace irqchip, then check if we need * to tell a userspace irqchip about timer or PMU level @@ -809,8 +811,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) */ smp_store_mb(vcpu->mode, IN_GUEST_MODE); - if (ret <= 0 || need_new_vmid_gen(&vcpu->arch.hw_mmu->vmid) || - kvm_request_pending(vcpu)) { + if (ret <= 0 || kvm_vcpu_exit_request(vcpu)) { vcpu->mode = OUTSIDE_GUEST_MODE; isb(); /* Ensure work in x_flush_hwstate is committed */ kvm_pmu_sync_hwstate(vcpu);