Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1857079rwb; Fri, 19 Aug 2022 10:31:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR4NX2UqfZBkHCn39izdDLGl5cmXH3g6wjbvqrUUcDeuwrVeJ99EgIpRUpyTAgGjJQwvoZ7p X-Received: by 2002:a05:6a00:23d1:b0:52f:39e9:9150 with SMTP id g17-20020a056a0023d100b0052f39e99150mr9042597pfc.16.1660930304530; Fri, 19 Aug 2022 10:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930304; cv=none; d=google.com; s=arc-20160816; b=0GHVr2TjAZyDe1c2ffhT4M9oWTlLiDTizgjXIHtpelwYN5rI2BAjg7iDPjROeHdTIZ D9/WGrqIMpF8i7BARtYTpa6aE0NQhr+inujiO4zjHD0D8VVNJHEfj9Ie2mywsnejXAbp kXMza9pYfZ3bCGuNndCfz895ApETZF+d9Lud+JxQhzvDblpBchOiayGObOXc9Qw3cnho 90h/FqMsJw08itMWpOPfdzywrkiJXDCcwGK+Uu0Dn7eUyUglGNoZw2VRcPsXpcbtSrpc E0+nzYMVlE93RTj4xmtlOXgFukxM33gB6gwamSYJcaWqYytzfjbPn5dD45UUfnMuJ4W0 QRPw== 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=kJwoOxGI2T9Qt/xUoLDH3huzLUUCopVG4lY7UqnUyzI=; b=maGNC3ZVzHhklBBlkf6leafNVcwn18H1Nefj0ZOki+yin7Y5HwXHpZMJivDH4gHuIp I7KcKXVjdTD033Ie1yLG7E4AVUza6qp4uKmSIJX5Z/wVY552Clzr/6CqmATnH/5F3C20 gUK7J+OBeixFTTjmAqUxfVgLGXJWuJRyx6ZZezY1txeilRriRvwFW6JIpRQc4OmiSvDf W7URFxc4smF4EBm1e+Uipt8aD/ffdND/1bW9+PPp1ZA/L73mTevIcc3za9H5Xq5ld4Vo 3ebzcgyniApKxxoiKu647ARHmgy3AnDmX7p9o1o6ynUOrJylpfmxRISSWr1IDhJZYhwO jbXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WPcIYpfx; 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 oo17-20020a17090b1c9100b001ef69a94be2si8344487pjb.134.2022.08.19.10.31.33; Fri, 19 Aug 2022 10:31:44 -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=WPcIYpfx; 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 S1354070AbiHSQrE (ORCPT + 99 others); Fri, 19 Aug 2022 12:47:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353751AbiHSQpL (ORCPT ); Fri, 19 Aug 2022 12:45:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B72510EEF0; Fri, 19 Aug 2022 09:11:29 -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 ams.source.kernel.org (Postfix) with ESMTPS id 726BCB82804; Fri, 19 Aug 2022 16:09:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E01F4C433D6; Fri, 19 Aug 2022 16:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925396; bh=MaGMXRIlJ9pG07km76Li0uZMw63W0tee65bOyaB3NMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WPcIYpfxD16IkDAmQH79SJ1gvX4/tBkf7M5uaMm/gWBGc5Nm86tSkX05lWUewrqj5 ivKrC5+Eumn+lQqg3F/qH3FIBSLrbZpWXWYd29HfSus97XIZTXtFrDMuPMQ+mHVZPI W/y3Du7BABMmvs4NJWPLAEe0S7Zipta/FpE6x+0k= 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.10 471/545] KVM: x86: Signal #GP, not -EPERM, on bad WRMSR(MCi_CTL/STATUS) Date: Fri, 19 Aug 2022 17:44:01 +0200 Message-Id: <20220819153850.484320566@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 23a5e5880615..98422a53bb1e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2869,13 +2869,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