From patchwork Mon Aug 4 08:02:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharat Bhushan X-Patchwork-Id: 376154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2D66D140142 for ; Mon, 4 Aug 2014 18:05:54 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731AbaHDIFx (ORCPT ); Mon, 4 Aug 2014 04:05:53 -0400 Received: from mail-bl2lp0209.outbound.protection.outlook.com ([207.46.163.209]:24357 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751598AbaHDIFv (ORCPT ); Mon, 4 Aug 2014 04:05:51 -0400 Received: from BY2PR03MB572.namprd03.prod.outlook.com (10.141.143.152) by BY2PR03MB192.namprd03.prod.outlook.com (10.242.36.144) with Microsoft SMTP Server (TLS) id 15.0.995.14; Mon, 4 Aug 2014 08:05:31 +0000 Received: from BY2PR03CA069.namprd03.prod.outlook.com (10.141.249.42) by BY2PR03MB572.namprd03.prod.outlook.com (10.141.143.152) with Microsoft SMTP Server (TLS) id 15.0.995.14; Mon, 4 Aug 2014 08:05:29 +0000 Received: from BN1AFFO11FD028.protection.gbl (2a01:111:f400:7c10::193) by BY2PR03CA069.outlook.office365.com (2a01:111:e400:2c5d::42) with Microsoft SMTP Server (TLS) id 15.0.995.14 via Frontend Transport; Mon, 4 Aug 2014 08:05:27 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD028.mail.protection.outlook.com (10.58.52.88) with Microsoft SMTP Server (TLS) id 15.0.990.10 via Frontend Transport; Mon, 4 Aug 2014 08:05:27 +0000 Received: from kvm.ap.freescale.net (kvm.ap.freescale.net [10.232.14.24]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s7485CIB002141; Mon, 4 Aug 2014 01:05:24 -0700 From: Bharat Bhushan To: , CC: , , , Bharat Bhushan Subject: [PATCH 4/5 v2] KVM: PPC: BOOKE: Clear guest dbsr in userspace exit KVM_EXIT_DEBUG Date: Mon, 4 Aug 2014 13:32:42 +0530 Message-ID: <1407139363-25598-5-git-send-email-Bharat.Bhushan@freescale.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1407139363-25598-1-git-send-email-Bharat.Bhushan@freescale.com> References: <1407139363-25598-1-git-send-email-Bharat.Bhushan@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(189002)(199002)(46102001)(76482001)(104166001)(74502001)(81342001)(4396001)(68736004)(21056001)(6806004)(48376002)(88136002)(19580405001)(87936001)(47776003)(229853001)(105606002)(50226001)(64706001)(99396002)(26826002)(92566001)(81156004)(83322001)(84676001)(76176999)(62966002)(50986999)(69596002)(87286001)(19580395003)(79102001)(44976005)(83072002)(89996001)(74662001)(81542001)(31966008)(95666004)(92726001)(97736001)(107046002)(102836001)(20776003)(77156001)(36756003)(104016003)(106466001)(93916002)(77982001)(86362001)(85852003)(80022001)(50466002)(85306004); DIR:OUT; SFP:; SCL:1; SRVR:BY2PR03MB572; H:az84smr01.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 0293D40691 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=Bharat.Bhushan@freescale.com; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-OriginatorOrg: freescale.com Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org Dbsr is not visible to userspace and we do not think any need to expose this to userspace because: Userspace cannot inject debug interrupt to guest (as this does not know guest ability to handle debug interrupt), so userspace will always clear DBSR. Now if userspace has to always clear DBSR in KVM_EXIT_DEBUG handling then clearing dbsr in kernel looks simple as this avoid doing SET_SREGS/set_one_reg() to clear DBSR Signed-off-by: Bharat Bhushan --- v1->v2 - New patch (separated from guest debug emulation - Added description arch/powerpc/kvm/booke.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 322da7d..5c2e26a 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -735,6 +735,17 @@ static int kvmppc_handle_debug(struct kvm_run *run, struct kvm_vcpu *vcpu) struct debug_reg *dbg_reg = &(vcpu->arch.shadow_dbg_reg); u32 dbsr = vcpu->arch.dbsr; + /* Clear guest dbsr (vcpu->arch.dbsr). + * dbsr is not visible to userspace and we do not think any + * need to expose this to userspace because: + * Userspace cannot inject debug interrupt to guest (as this does + * not know guest ability to handle debug interrupt), so userspace + * will always clear DBSR. + * Now if userspace has to always clear DBSR in KVM_EXIT_DEBUG + * handling then clearing here looks simple as this + * avoid doing SET_SREGS/set_one_reg() to clear DBSR + */ + vcpu->arch.dbsr = 0; run->debug.arch.status = 0; run->debug.arch.address = vcpu->arch.pc;