From patchwork Wed Apr 19 02:18:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 13216286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2FFAAC6FD18 for ; Wed, 19 Apr 2023 02:20:16 +0000 (UTC) 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:Message-ID: References:Mime-Version: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=UwNxD6yhqkVUBu6+Jm6Voqx+wS6mlwfnXDK5oF8M6LU=; b=haG8fq/gYzoiKou7AF5Q1fLA0N fLHnE/hkTqL2HLJlRp0gcNlCCt4hwyFEe94i51KJFGsxY+GnpBB/VHYxBcEXWpxWL96XYcHYPkgM3 QH9QpMFVMxppzPlfDlHYkp2Q88WJOEVfpJtqvxp//nLI2SocRyMn1WGJYbSOPMugGe8aBWIbXbTLU cz3vEXDQ9kYckIvepYZ1yLK934GPEcRnbmortbhWyD+CCxAsjY4erf+d3N/riyBjVP/FJ2CbcEr5p 20SNdbffy6nekMMv+YKzY4EDd0FZFiMRvUV21R0Nns9Ml2AVl3yU+FWKuOQn/ZEGjS8AtLbochkfK UowpirVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poxPi-003lsn-0s; Wed, 19 Apr 2023 02:19:18 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poxPb-003lpZ-0a for linux-arm-kernel@lists.infradead.org; Wed, 19 Apr 2023 02:19:12 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id d132-20020a254f8a000000b00b868826cdfeso5551306ybb.0 for ; Tue, 18 Apr 2023 19:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681870746; x=1684462746; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=z7zzcGDZPbSte4f8fT9vbCw5LuF4xstdxjEG9JI5LdU=; b=1BpmpgNYdsRKvRk6qrTEJbdcclnYFCXUZ1sKONbsw5Ac+UIEhNn+Cnjg4xjnCGB5JQ Shim51D/sV8i+svuoxMw06bFf0Ucel+aJs/jZJJQ1BNVWu7V4xKCnMR7ZBqzsal8nEcV kZiYnCBxW/ZfmJF0FbIPl2er+nfPek/CxhnGqU0yeGxTQkO0OY60TJ9f3whZk7pwzDPA rVKqlgZTUyLiVhks/K6jyM9QOfSJkfori6PQ0DzF2ye/sOHYLOlYUmsp0B2Nv5eywmkS EwDe+BL0VSwDvG3ugu5GwSLOR0/NsBzFakFVtuLsKy/yuAWsB+PVHPnR285JBPVa1X9+ hNhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681870746; x=1684462746; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z7zzcGDZPbSte4f8fT9vbCw5LuF4xstdxjEG9JI5LdU=; b=BA0gvfcTduaGKMgN8g3Qnk31YXh9zmafEKQcX3w7J0U1LSB6pBft14E5rSZbPIHTkz bO3oF0enL2XeVgr0bNsiWehjLTC198y2ZsKWIvuJiiel5bImuJLZ6qT7aVZySud+6N4l CNQ1xj33UxD7WOXEg2VOLSKOm5Fc9DmqFhZ4f/JfGFVzh/Gn4JAYFmL8R1mwo6ZkDGGo yLOA03KY0J8iNOZxxUHsn8RrH/CDkaIZeJtY8WRXiOtL7uJZca0ipOrifnwgjWQYi2Rc iC9EbtknD8EUqPVTisjn9+pqrqUDCsdADY8UfOTQR3PIi5Pa9fikZqlpRf7i7fHjytcn VVGQ== X-Gm-Message-State: AAQBX9cBbp8z8X4+u2PmTxYpVKb3ZS4DURmgPoW+l+v+4Y/89yZwAID6 QV+Ac4teW7KkQ0oZ7VF17rzXju8rMfE= X-Google-Smtp-Source: AKy350Z/I1GCXlm8WzCDIqkLOeoag4XllnSKJRp0ZAYYdDCimf2ANR08QBaZ+Z2bMGMmbTBDeu0l1oEfJ0E= X-Received: from reijiw-west4.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:aa1]) (user=reijiw job=sendgmr) by 2002:a25:d814:0:b0:b96:7676:db47 with SMTP id p20-20020a25d814000000b00b967676db47mr433801ybg.13.1681870746505; Tue, 18 Apr 2023 19:19:06 -0700 (PDT) Date: Tue, 18 Apr 2023 19:18:51 -0700 In-Reply-To: <20230419021852.2981107-1-reijiw@google.com> Mime-Version: 1.0 References: <20230419021852.2981107-1-reijiw@google.com> X-Mailer: git-send-email 2.40.0.396.gfff15efe05-goog Message-ID: <20230419021852.2981107-2-reijiw@google.com> Subject: [PATCH v1 1/2] KVM: arm64: Acquire mp_state_lock in kvm_arch_vcpu_ioctl_vcpu_init() From: Reiji Watanabe To: Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Zenghui Yu , Suzuki K Poulose , Paolo Bonzini , Ricardo Koller , Jing Zhang , Raghavendra Rao Anata , Will Deacon , Reiji Watanabe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230418_191911_220715_A5D6B4D5 X-CRM114-Status: GOOD ( 12.92 ) 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 kvm_arch_vcpu_ioctl_vcpu_init() doesn't acquire mp_state_lock when setting the mp_state to KVM_MP_STATE_RUNNABLE. Fix the code to acquire the lock. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/arm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index fbafcbbcc463..388aa4f18f21 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1244,8 +1244,11 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu, */ if (test_bit(KVM_ARM_VCPU_POWER_OFF, vcpu->arch.features)) kvm_arm_vcpu_power_off(vcpu); - else + else { + spin_lock(&vcpu->arch.mp_state_lock); WRITE_ONCE(vcpu->arch.mp_state.mp_state, KVM_MP_STATE_RUNNABLE); + spin_unlock(&vcpu->arch.mp_state_lock); + } return 0; }