Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3258835rwb; Mon, 15 Aug 2022 22:32:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR6+R+ajmawAbiQNI2E4fM4gUz5+CSsXLTstdmDoxDFxqdfydJwS1c3y9FIPakthNLdNEN6p X-Received: by 2002:a05:6a00:2195:b0:52e:6157:904d with SMTP id h21-20020a056a00219500b0052e6157904dmr19526041pfi.44.1660627934135; Mon, 15 Aug 2022 22:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660627934; cv=none; d=google.com; s=arc-20160816; b=McAy61EZYXX7GnDdJhYQV//qKZnqcHkfQhx1yqMoU3LR4JqAnAj6fCxvddrv5WHWM5 j4MXIeBLu1ZH7zSekmdmultUJBrKqINXXrout8xa2gTQkIOE1JieJDnQe5gtiX//tex3 onO3qeD+6GjBdKNJQf6WpGKy6TUs7r0lzanR5huWykR2BSxvG7eqtu+MJDgjKtdZgJI/ mmH/s/8PCBRhi+b9fV7rdKHC9Mge+QwK5k0sPJibUKT1ly5WpsZIRpl2ditSV6ptIvSe EN1XL5HF92xlWLydpoYWv9OEer66U5MPtAclxFlMTcU7BngQGemBNfRU6mgbXgGY6tJU S+9g== 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=1Hz5WnFPNTgj3yoQev3hJxKUYKJydk+WOT+cfz+gzkg=; b=0r/ltfoftMY7rQz5LZUZ15Apdf7MMIvV7kxbW2x64t8Tu9vNTvzWiFNVqjXrjNhEkN StTlvOZdwycExqgcfToop/bvkzBMiHf56y3sdfTZOCmOFnaqV5jKJQoTWVpKY6hmSbRy RUiZ0jNh/O7D31gjBNGotZ7lQx9wi5tGe2gnZVpObZ0m2XoQGNNCour84/exOxJ1qcHH gneQX1FW+mU5lMduVZPbszLB20UD201qAjm4dyYftuEnKdCj/Wo/ErvINwuZDkMrVFx0 XjdXznsO+5wZGi97kqO6bIx1577Xf9/qxCvHPZ5SzC44co8Io7BU/bTA4Og7C1YdjFVr 62LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tAwdSew9; 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 h10-20020a63530a000000b0042814932da7si6702037pgb.403.2022.08.15.22.32.03; Mon, 15 Aug 2022 22:32: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=tAwdSew9; 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 S233102AbiHPExO (ORCPT + 99 others); Tue, 16 Aug 2022 00:53:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232946AbiHPEuA (ORCPT ); Tue, 16 Aug 2022 00:50:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 737DB198EF0; Mon, 15 Aug 2022 13:46: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 dfw.source.kernel.org (Postfix) with ESMTPS id 40A3F61243; Mon, 15 Aug 2022 20:46:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E1F6C433C1; Mon, 15 Aug 2022 20:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596388; bh=95MZa6uD0zu+Km9ttQRIJ1lsVdf+S8PpnWUB0jn7cXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tAwdSew95jr40uEjpZnGvsgGr7t7Aj/zMi9tWrE5yBihFNpD/WWmneUuGsGBezrua Fw/0l/Dn9JZGGicZ9QGlcLvH8V0gGoBXQVNNkaeP+jRyyQdOeiwSLpC7ZC9FWcRXju 3N1VMmukO8OYUoX/S7tC4yuYuRP6a7wRoqqTY2ig= 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.19 1064/1157] KVM: x86: Signal #GP, not -EPERM, on bad WRMSR(MCi_CTL/STATUS) Date: Mon, 15 Aug 2022 20:07:00 +0200 Message-Id: <20220815180522.633495804@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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(-) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3252,13 +3252,13 @@ static int set_msr_mce(struct kvm_vcpu * */ 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;