From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19C1BC433EF for ; Thu, 12 May 2022 22:27:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359174AbiELW13 (ORCPT ); Thu, 12 May 2022 18:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359139AbiELW1W (ORCPT ); Thu, 12 May 2022 18:27:22 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 152BD68FAE for ; Thu, 12 May 2022 15:27:21 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id ij27-20020a170902ab5b00b0015d41282214so3360593plb.9 for ; Thu, 12 May 2022 15:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=C1tmuGf3Kd7bX6AU3hgvhdPKig3pohM2CuCo9pbL7R4=; b=GQ3TiTInl8g97+ab53I7+wOlfYIibpi1MwqEhIfwQfpbg/6/HMjl/L86q4NTrWM0dM 05ZvPnReez1qICDspanXCUPjFsjzwBu0BBUj3kX8ciEISZBr6TIMzKbGZKLEY7J5FK18 sSJbmY2nlZXmhk9jpc02Uci9pJHtFV2qawWnjJJTDVt+W5U5vxt9rAOEjF/iSAFU0/qJ idb9XzQiNlN9Aj7g2scAGXMAESLrT3FQfUjRQl1Wo37TW81PWKygJJZU10A7FUzgGEaq 2J80DftcI5y7GHShiS9p3WCjfcA3j7X1J0GsmYJwXSJIQF2f/PbM8BMcri0IC+st8DV6 JFXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=C1tmuGf3Kd7bX6AU3hgvhdPKig3pohM2CuCo9pbL7R4=; b=D0BHTtlP522IbeIY0tWnkbUwidlXzCirpDjE5T77PHGZitTUffTrLAgsb5AnNdueN3 sz5EcxFO64YzVJEfifzsAckwuTIvlo66lPdjVy4jTKbd2rQ/d+glwoE4bSG9eLnnj5FL 2dE6pafEvLW8tLkzOEJjan9+Hp6P9+HZN7iwwjw4JZuLK+LCSqyGnhQgdD+UCug0ujZj 9XQAe6r1rkrP/+SNucbB9V0EqKYhGQmy5RcPYSrF0Qnvu8rUhWi8ZJZz4WgGkmS2TlYK 1EM2ufqFrgYf8sQDuMLFjdz/mKFRsCvwjD2Cfi9Bu/PcI5PbvgVP93RJoru8CZhjMdGV Unkg== X-Gm-Message-State: AOAM5319ADGlzBwd8D/xNPgpPy3ECw8lkwNcN9Dp7AkaZ8l5DDWXQIDF 6zHbV5zIQBtgan3chpUcQiz/yyupWpk= X-Google-Smtp-Source: ABdhPJxHlQ48LjPdMReroSi+205tvMnzQqeslUkAQ4n7oeIV1go/ikXM5Elxq2fyC/ZXARh+nVKIAts+k58= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a62:31c1:0:b0:50a:4909:2691 with SMTP id x184-20020a6231c1000000b0050a49092691mr1511291pfx.64.1652394440586; Thu, 12 May 2022 15:27:20 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 12 May 2022 22:27:14 +0000 In-Reply-To: <20220512222716.4112548-1-seanjc@google.com> Message-Id: <20220512222716.4112548-2-seanjc@google.com> Mime-Version: 1.0 References: <20220512222716.4112548-1-seanjc@google.com> X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [PATCH 1/3] KVM: x86: Signal #GP, not -EPERM, on bad WRMSR(MCi_CTL/STATUS) From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jue Wang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 8ee8c91fa762..bc6db58975dc 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)) != ~(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.36.0.550.gb090851708-goog