From patchwork Wed May 4 03:24:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12837106 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 4B7B8C433F5 for ; Wed, 4 May 2022 03:29:18 +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: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=Tjgg5alrcDqjDDoL/93qZvt9khTfqvR2NBpbmGvt+bQ=; b=qj3PAAnYx+ZttpcV2eG7CQk3Zt W1PqeAeKENUQVlYufIZ31edWnPX5ylk8EOnoyV826jrOqljf1T/bBCINa31vFZH1QFLDe8to9GS4j 5bkXCk00/vsvL+xci+jMqZOWAGmB5nBsbVduAOt+IYLRBiKMcQv5pbCadUqdkht7hC5sEsEEIhmg9 Fi8O5q+Hpe7ImX6PRGIRsIj//wyg2P49AGBtdAMPi11lL/BTThZZsJmvJApNxHbvHVSvZvjBHAPcA ey11sVpmCAT0pdN4J22wFBN83k0VOAh0pnYDDRQEup9g7g8oYC8mcSqs8D8aSOecqinOudu96rusQ dUxPPR3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nm5gO-008aLf-4M; Wed, 04 May 2022 03:28:08 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nm5dW-008YTI-VS for linux-arm-kernel@lists.infradead.org; Wed, 04 May 2022 03:25:12 +0000 Received: by mail-pl1-x64a.google.com with SMTP id ij27-20020a170902ab5b00b0015d41282214so141890plb.9 for ; Tue, 03 May 2022 20:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=vC3V+2CBJIc1C3R9s0y8nQnpmWBf83eXJD/GXiFHTxk=; b=i8yg46C8ANIA2EeY47SlTmObZ07geosP5go76P5bWKcOMH+uyUCxbwt2Kk168LIZHI LCNQZ3JxYIR6TmH+z2dqzuWIzq9GEKZ9n8W3JhDZXCRzh9m6SY2QF49N9xrhjOKjwHCg WIQDqZfNFaPw/Cod7ereFSUKrvtslwg2TmcmogERVoq2xsGKHFhX5xqeexzxnHIIyIGL BgPIoNlIoFuoWxdieMBrNc8F3m5kh9R9WSQifwTdGoUmhuZ7v86yEkdFWi0q9n88CFVd +i1Hw4yEvtj2vHYZ7/sgTOgNDW6jj2KLz2QNUJ/FSbyJkqgusc+FLhyoyF6Fquf/kbfR cXNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=vC3V+2CBJIc1C3R9s0y8nQnpmWBf83eXJD/GXiFHTxk=; b=01930L7wL8SqQ0UGhEof9qf2iG2GizBA9BkoG9T0VjNQKOZ1p2DAY4XMHx3kaMpXlK M7SsDOqNGgJyyRhAgY4bHQ7Tk+o4KPdgBwmpi7dOxFpMwes2NF0kUqIr2OfumDyFXa8W GrhBynvEnC8fKe3K1f7kQsIH8AsHk1VaAWJq4DXkVFH2bZmjWRCWrwTc8n9z1xrYnR8A ZqzgzQdZofDJaKPtbqoDuwYCeotBx4Y33eQQIyH0IPuidV/YZ7JFxrs4zYek/5PkcuDp cNi0ZaBafw9YIm1CJKvsjinK8Qfq8fZeJhFXPaL3EiCAeysxjyoithxR+nPJ3eIqDbZM dt1A== X-Gm-Message-State: AOAM531NGFN+hNUnrJYWmmwl9Ptc1x95kpZDSRJbGPEpry6jiwYdKllb pl2PXKIRijSiKC00Zux/5TMbZZO+Hb8= X-Google-Smtp-Source: ABdhPJym7VaWlC5x9ioDgbuAXxdKjWGCuRNU6ZzBqtt+v8vwKT5s0AloQM3OscjKyqjYn0lPOfjYJrrWKWI= X-Received: from oupton3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:21eb]) (user=oupton job=sendgmr) by 2002:a17:90a:dd45:b0:1bc:9466:9b64 with SMTP id u5-20020a17090add4500b001bc94669b64mr8262744pjv.23.1651634709842; Tue, 03 May 2022 20:25:09 -0700 (PDT) Date: Wed, 4 May 2022 03:24:44 +0000 In-Reply-To: <20220504032446.4133305-1-oupton@google.com> Message-Id: <20220504032446.4133305-11-oupton@google.com> Mime-Version: 1.0 References: <20220504032446.4133305-1-oupton@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v6 10/12] selftests: KVM: Use KVM_SET_MP_STATE to power off vCPU in psci_test From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, reijiw@google.com, ricarkol@google.com, Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220503_202511_036715_DBC33023 X-CRM114-Status: GOOD ( 13.05 ) 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 Setting a vCPU's MP state to KVM_MP_STATE_STOPPED has the effect of powering off the vCPU. Rather than using the vCPU init feature flag, use the KVM_SET_MP_STATE ioctl to power off the target vCPU. Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/aarch64/psci_test.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/psci_test.c b/tools/testing/selftests/kvm/aarch64/psci_test.c index 8c998f0b802c..fe1d5d343a2f 100644 --- a/tools/testing/selftests/kvm/aarch64/psci_test.c +++ b/tools/testing/selftests/kvm/aarch64/psci_test.c @@ -60,6 +60,15 @@ static void guest_main(uint64_t target_cpu) GUEST_DONE(); } +static void vcpu_power_off(struct kvm_vm *vm, uint32_t vcpuid) +{ + struct kvm_mp_state mp_state = { + .mp_state = KVM_MP_STATE_STOPPED, + }; + + vcpu_set_mp_state(vm, vcpuid, &mp_state); +} + int main(void) { uint64_t target_mpidr, obs_pc, obs_x0; @@ -75,12 +84,12 @@ int main(void) init.features[0] |= (1 << KVM_ARM_VCPU_PSCI_0_2); aarch64_vcpu_add_default(vm, VCPU_ID_SOURCE, &init, guest_main); + aarch64_vcpu_add_default(vm, VCPU_ID_TARGET, &init, guest_main); /* * make sure the target is already off when executing the test. */ - init.features[0] |= (1 << KVM_ARM_VCPU_POWER_OFF); - aarch64_vcpu_add_default(vm, VCPU_ID_TARGET, &init, guest_main); + vcpu_power_off(vm, VCPU_ID_TARGET); get_reg(vm, VCPU_ID_TARGET, KVM_ARM64_SYS_REG(SYS_MPIDR_EL1), &target_mpidr); vcpu_args_set(vm, VCPU_ID_SOURCE, 1, target_mpidr & MPIDR_HWID_BITMASK);