From patchwork Tue Mar 22 18:35:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12788937 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 C4E9BC433F5 for ; Tue, 22 Mar 2022 18:37:33 +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=n5c5oqTCjyiEZT1DC12tY+P2tKGzt/lA28ImkDF1DAM=; b=i0CI+u/vZCQL4dwy0AAmTiFQ7w vMcDJo8Qva9wo8epkcm04BSd6JQJ+Xh4az2JGgds6VnjnQdcwFn0ZfOJXZVY7RovtGXZkLTbe4TLn avFp92rzOuJd8V0d1a+cxGat5I4CZLJ9dOTnKGRvMwWY4jNtdOCTr4d1wtmXDs1iCK7GnP5/GD/wq 4nAUx9DGehactFdB+9Ob2mJLVO9LKyRobrcCs4/CHQ6raj0/WeieNjIpx2VQREFQZ7iJ3KRqHtOSg ZYERJGMV8XvVvG6iJ1YlohFSWO4YjGWpGnTcWNPLoBvGUkwUWoYSQdlmE/9GrXiDLHawEVYb9Ua2I iDG2EfhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWjMl-00Bt0e-At; Tue, 22 Mar 2022 18:36:23 +0000 Received: from mail-io1-xd4a.google.com ([2607:f8b0:4864:20::d4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWjMD-00Bsoe-98 for linux-arm-kernel@lists.infradead.org; Tue, 22 Mar 2022 18:35:50 +0000 Received: by mail-io1-xd4a.google.com with SMTP id h14-20020a05660208ce00b00645c339411bso13001076ioz.8 for ; Tue, 22 Mar 2022 11:35:47 -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=lGW+qCdwzMwtGGlVg3y2ePu73Q+JTzIqWyWeB9h5azY=; b=Q4h5St4bE4rOW155Wn3EO80R//PDfJqRJZaeS2M2PHHwYAb5zLlzGAVLgI+8KcM5ue vASo5TsEVfEDWKQe/g/0ORUybF8ztFa/MVDOQTAcoaq+H538ch/z0Yxpf5sxOtMhO/mj 1NvKR21tAZKlMkbhpGRqDnpFi0D2OUA2wDtnJwJEzaeaHmJNhVRNzuckM5UlO7U51Ccc YITlUK4lhH8zzVZtT2cDQSglIjKg4ygFpPgqjdjQ65imS+SRIzOc+5z7sPxPB2ce2sdq 735gTDGZlMN8ChNHrTDGsmrGpERbIKbMzkO6tB3B2eNNL7XLUe98wL3O7tuwW3BJpocx qdZA== 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=lGW+qCdwzMwtGGlVg3y2ePu73Q+JTzIqWyWeB9h5azY=; b=cz7i9iJurAbjK2AQXGHKuYZdTcinDxLU8rZl5rjlIY2dvZbAC6Pqm2ouSCgmC5Gn9a +d9T5r6CYjKTUqefq9f7qtxXvtwxmiyXKVTMmJwQI8ClPD2IHbWHQ54DrMD+9ANBDIN0 ZpU8zQsqBM8eM1pAsmWEVDVbUaZ8KzVL4pOdXq3e9f5T57lpTEC2F3s1Y9+Kml6wfqAy Wf4v9gGY+cEa5LdaNZlJcAnwG3kx4PdgoukEsjYpjjiViSGXYCotqoCBGS2QGOh/zJXd +AvLo1tvt3i9jCxdHSSCrcEkakeJ0EXh/n3y8/0DAO5dlKAJwuumxAb6+ePBTQqylyxx VvnA== X-Gm-Message-State: AOAM5316wkfX25NCLpq13ozwX5tPRfGqIqIXxAPirj4W7xB4KX0WKYKj ba+rq1edRkSVwffujda8fNPyL53FSyQ= X-Google-Smtp-Source: ABdhPJxYqKXNgdI2Nn0wjD8p/zp8eXY/Rgm3sPEio6NQXm4jTPjyEFh8n9PKO7v2VGbk1KOuPT1TekwRGKE= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a92:d486:0:b0:2c7:b549:ede7 with SMTP id p6-20020a92d486000000b002c7b549ede7mr12361089ilg.84.1647974147115; Tue, 22 Mar 2022 11:35:47 -0700 (PDT) Date: Tue, 22 Mar 2022 18:35:38 +0000 In-Reply-To: <20220322183538.2757758-1-oupton@google.com> Message-Id: <20220322183538.2757758-4-oupton@google.com> Mime-Version: 1.0 References: <20220322183538.2757758-1-oupton@google.com> X-Mailer: git-send-email 2.35.1.894.gb6a874cedc-goog Subject: [PATCH v2 3/3] KVM: arm64: Drop unneeded minor version check from PSCI v1.x handler From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Peter Shier , Ricardo Koller , Reiji Watanabe , Paolo Bonzini , Will Deacon , Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220322_113549_381925_0A982B92 X-CRM114-Status: GOOD ( 11.82 ) 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 We already sanitize the guest's PSCI version when it is being written by userspace, rejecting unsupported version numbers. Additionally, the 'minor' parameter to kvm_psci_1_x_call() is a constant known at compile time for all callsites. Though it is benign, the additional check against the PSCI kvm_psci_1_x_call() is unnecessary and likely to be missed the next time KVM raises its maximum PSCI version. Drop the check altogether and rely on sanitization when the PSCI version is set by userspace. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/kvm/psci.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c index d24ccc77500b..0b1b588f1f9b 100644 --- a/arch/arm64/kvm/psci.c +++ b/arch/arm64/kvm/psci.c @@ -310,9 +310,6 @@ static int kvm_psci_1_x_call(struct kvm_vcpu *vcpu, u32 minor) unsigned long val; int ret = 1; - if (minor > 1) - return -EINVAL; - switch(psci_fn) { case PSCI_0_2_FN_PSCI_VERSION: val = minor == 0 ? KVM_ARM_PSCI_1_0 : KVM_ARM_PSCI_1_1;