Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3031842rwb; Mon, 15 Aug 2022 16:31:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR5RNuhfUgathB+huJuetJsrniCjdALItZuJMb+6eKc/mwEgBUoa2kcDm5/Pq6Nnz/scdrmW X-Received: by 2002:a17:907:6e17:b0:731:2426:f606 with SMTP id sd23-20020a1709076e1700b007312426f606mr11625709ejc.162.1660606274480; Mon, 15 Aug 2022 16:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660606274; cv=none; d=google.com; s=arc-20160816; b=rNQUIirJQmQcwPuDJtQHYgWcDk6k8vlAk1l3oSDs1sYeeQ8z0NTu96mySOL+eizV0z Lakd2nDXgsVzUkzc9zwfkfl5HPlpRx5k/bdm6eM9VchUurg+hB2tDX3rbuzs5RKYD33A qJrYObWiFo9Xyq4L8KqtHe3JQn0kNj3Ie+XPYl5CaRKdDJjmBbhOnnJiwMUOQvt7zRt/ coN1ozNEuPmNW0bqyQ3YxADk4ZxVp+sZ5gXR7d6AUAmtpapPTxjZuzv2TyxiXITMId+P bVu0sS9SU8ew3Qt0i5iIgD506QmZSMgpGErWC+F26vXwr/26ZlohdW8uoAuDokLbLpWc HZaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m1pIAEpvYaT/rSXi9O4D0uN1f32jP0xKbd+vmIhRFLM=; b=prsPs/8rQEvc+334+ImOZIAKv/aHHj42f9wWaM4TMWGNWYH2A4UxFpiVGsAtAv6s9D XSM8cx4b8u9/BkmxFxmcmhtlAqVCt1POjKZujYa2FjDEZE9fOLCr9uGdX0L2Ex4OSfhJ GLyIK2vXcUUGV1mex7glM0nn0a2Zl1KIJYNt/Y+s9M5vtyKStmWImj5TtBQ3iZVEd4I9 nbMyNG2QoX9AVRDGeN74G7BPNzLXA7fKyr/d2Zg5eElnqUw+Nti2xA4eCDK8GjqUwrus drswQKkjhwwuQMdi2pciT096rsrEMMK+0WBZOapdUjYXVdChUgHarky3GFxDd/CGY3qF MxRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QPie6zsP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp36-20020a1709073e2400b00722e3682c3bsi9567874ejc.257.2022.08.15.16.30.45; Mon, 15 Aug 2022 16:31:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QPie6zsP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353235AbiHOXV7 (ORCPT + 99 others); Mon, 15 Aug 2022 19:21:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344591AbiHOXO3 (ORCPT ); Mon, 15 Aug 2022 19:14:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8147A530; Mon, 15 Aug 2022 13:01:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BCC9B61299; Mon, 15 Aug 2022 20:01:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1DA5C433C1; Mon, 15 Aug 2022 20:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593710; bh=uWra+Qzx8ugDojYZaaq+pat/bESp/okATL7sH1tOtCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPie6zsPD2LRg5oww06kOVWV+MxtSmQl9Gs0cwl4N2Sg+luR2pK/lwy5nzV0nHrmv Uo7kryncDsICRT7vAKRqpzV6xVKzWYrRLkg/s293dT0kEHF1IWXQp+0oFFPrM5oxZv ScSOKF2Dx9R90fFHRcitPZCQvR30sQeIVMW1kCq4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Jim Mattson , Sasha Levin Subject: [PATCH 5.18 0994/1095] KVM: x86: Signal #GP, not -EPERM, on bad WRMSR(MCi_CTL/STATUS) Date: Mon, 15 Aug 2022 20:06:33 +0200 Message-Id: <20220815180510.231278419@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson [ Upstream commit 2368048bf5c2ec4b604ac3431564071e89a0bc71 ] Return '1', not '-1', when handling an illegal WRMSR to a MCi_CTL or MCi_STATUS MSR. The behavior of "all zeros' or "all ones" for CTL MSRs is architectural, as is the "only zeros" behavior for STATUS MSRs. I.e. the intent is to inject a #GP, not exit to userspace due to an unhandled emulation case. Returning '-1' gets interpreted as -EPERM up the stack and effecitvely kills the guest. Fixes: 890ca9aefa78 ("KVM: Add MCE support") Fixes: 9ffd986c6e4e ("KVM: X86: #GP when guest attempts to write MCi_STATUS register w/o 0") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Reviewed-by: Jim Mattson Link: https://lore.kernel.org/r/20220512222716.4112548-2-seanjc@google.com Signed-off-by: Sasha Levin --- arch/x86/kvm/x86.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2316c978b598..0d6cea0d33a9 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3233,13 +3233,13 @@ static int set_msr_mce(struct kvm_vcpu *vcpu, struct msr_data *msr_info) */ if ((offset & 0x3) == 0 && data != 0 && (data | (1 << 10) | 1) != ~(u64)0) - return -1; + return 1; /* MCi_STATUS */ if (!msr_info->host_initiated && (offset & 0x3) == 1 && data != 0) { if (!can_set_mci_status(vcpu)) - return -1; + return 1; } vcpu->arch.mce_banks[offset] = data; -- 2.35.1