From patchwork Thu Jun 7 08:07:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Mackerras X-Patchwork-Id: 10451353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3B35560467 for ; Thu, 7 Jun 2018 08:08:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D72529A3A for ; Thu, 7 Jun 2018 08:08:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2212F29A43; Thu, 7 Jun 2018 08:08:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE0D229A3A for ; Thu, 7 Jun 2018 08:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753550AbeFGIIQ (ORCPT ); Thu, 7 Jun 2018 04:08:16 -0400 Received: from ozlabs.org ([203.11.71.1]:48487 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753068AbeFGIIM (ORCPT ); Thu, 7 Jun 2018 04:08:12 -0400 Received: by ozlabs.org (Postfix, from userid 1003) id 411dT66FlQz9s2t; Thu, 7 Jun 2018 18:08:10 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1528358890; bh=rm12zCSnsUPVQ4Ib4SK7pU3b5XCKs0R0k62KgSV7Zho=; h=Date:From:To:Subject:References:In-Reply-To:From; b=azgoeum35eEfwwYd7ZetKxqWbF926OyL7ihRF0JLFA1d6LY2/ZVQR7NMBw0ozzDLL /XcB0yY0gjr1ZqBmnEGJRc/YIH8+ixWlLkFm64WjPCJLIBExiElo0RKTDojwtjcSQh nN2x2rx5EWPL/Wp3cqgbFdhcQ8uUYSuDPJRUpCcAmMtLwHIcZwLg++6FajQM++deIm waxCuWA4XqAciiwDHkhscm6Q0CihIxXbrXTHdRTHGdYxREv1JvyG66xLeYlppRu4cX WFNJfyWLb6125TxEpTUTLGt16Kef70FCltg0wPhL0GBbR7isOHmcaZ3OHquKI8jhXr /zPcKqkITV24g== Date: Thu, 7 Jun 2018 18:07:06 +1000 From: Paul Mackerras To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Subject: [PATCH 3/4] KVM: PPC: Book3S PR: Don't let PAPR guest set MSR hypervisor bit Message-ID: <20180607080706.GC13401@fergus.ozlabs.ibm.com> References: <20180607080437.GA13401@fergus.ozlabs.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180607080437.GA13401@fergus.ozlabs.ibm.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP PAPR guests run in supervisor mode and should not be able to set the MSR HV (hypervisor mode) bit or clear the ME (machine check enable) bit by mtmsrd or any other means. To enforce this, we force MSR_HV off and MSR_ME on in kvmppc_set_msr_pr. Without this, the guest can appear to be in hypervisor mode to itself and to userspace. This has been observed to cause a crash in QEMU when it tries to deliver a system reset interrupt to the guest. Signed-off-by: Paul Mackerras --- arch/powerpc/kvm/book3s_pr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 5c708d6a44fb..c36c8ef3dfb0 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -456,6 +456,10 @@ static void kvmppc_set_msr_pr(struct kvm_vcpu *vcpu, u64 msr) { ulong old_msr; + /* For PAPR guest, make sure MSR reflects guest mode */ + if (vcpu->arch.papr_enabled) + msr = (msr & ~MSR_HV) | MSR_ME; + #ifdef EXIT_DEBUG printk(KERN_INFO "KVM: Set MSR to 0x%llx\n", msr); #endif