From patchwork Wed Aug 20 12:11:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 4750491 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 214069F344 for ; Wed, 20 Aug 2014 12:15:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50C05201BF for ; Wed, 20 Aug 2014 12:15:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 363BC2017A for ; Wed, 20 Aug 2014 12:15:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752778AbaHTMMG (ORCPT ); Wed, 20 Aug 2014 08:12:06 -0400 Received: from mailgw12.technion.ac.il ([132.68.225.12]:17370 "EHLO mailgw12.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752233AbaHTMMD (ORCPT ); Wed, 20 Aug 2014 08:12:03 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkAFAK6P9FOERCAB/2dsb2JhbABZgw0BgSmzH5kfh2iBERZ3hDFSgVGIQr07hGUXj0wdhDYFixydMYh8g2Bpgk8BAQE X-IPAS-Result: AkAFAK6P9FOERCAB/2dsb2JhbABZgw0BgSmzH5kfh2iBERZ3hDFSgVGIQr07hGUXj0wdhDYFixydMYh8g2Bpgk8BAQE X-IronPort-AV: E=Sophos;i="5.01,901,1400014800"; d="scan'208";a="119432636" Received: from csa.cs.technion.ac.il ([132.68.32.1]) by mailgw12.technion.ac.il with ESMTP; 20 Aug 2014 15:12:00 +0300 Received: from csn.cs.technion.ac.il (csn.cs.technion.ac.il [132.68.32.15]) by csa.cs.technion.ac.il (Postfix) with ESMTP id 6961E14003B; Wed, 20 Aug 2014 15:11:59 +0300 (IDT) Received: from csl-tapuz20.cs.technion.ac.il (csl-tapuz20.cs.technion.ac.il [132.68.206.58]) by csn.cs.technion.ac.il (Postfix) with ESMTP id 58AC5598005; Wed, 20 Aug 2014 15:11:59 +0300 (IDT) From: Nadav Amit To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, Nadav Amit Subject: [PATCH] KVM: x86: Keep masked bits unmodified on kvm_set_shared_msr Date: Wed, 20 Aug 2014 15:11:51 +0300 Message-Id: <1408536711-32643-1-git-send-email-namit@cs.technion.ac.il> X-Mailer: git-send-email 1.9.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, when an msr is updated using kvm_set_shared_msr the masked bits are zeroed. This behavior is currently valid since the only MSR with partial mask is EFER, in which only SCE might be unmasked. However, using the kvm_set_shared_msr for other purposes becomes impossible. This patch keeps the masked bits unmodified while setting a shared msr. Signed-off-by: Nadav Amit --- arch/x86/kvm/x86.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5f5edb6..ee42410 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -236,6 +236,7 @@ void kvm_set_shared_msr(unsigned slot, u64 value, u64 mask) if (((value ^ smsr->values[slot].curr) & mask) == 0) return; + value = (smsr->values[slot].curr & ~mask) | (value & mask); smsr->values[slot].curr = value; wrmsrl(shared_msrs_global.msrs[slot], value); if (!smsr->registered) {