From patchwork Fri Dec 18 17:36:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 7887311 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 414BC9F32E for ; Fri, 18 Dec 2015 17:39:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70A4E204D6 for ; Fri, 18 Dec 2015 17:39:24 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82869203E6 for ; Fri, 18 Dec 2015 17:39:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a9yxb-0004hT-41; Fri, 18 Dec 2015 17:36:55 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a9yxa-0004h7-7H for xen-devel@lists.xen.org; Fri, 18 Dec 2015 17:36:54 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id 5D/28-21571-53444765; Fri, 18 Dec 2015 17:36:53 +0000 X-Env-Sender: prvs=787b995ab=Andrew.Cooper3@citrix.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1450460211!6166663!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36341 invoked from network); 18 Dec 2015 17:36:52 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 18 Dec 2015 17:36:52 -0000 X-IronPort-AV: E=Sophos;i="5.20,447,1444694400"; d="scan'208";a="320339910" To: Boris Ostrovsky , Jan Beulich References: <1450393254-4285-1-git-send-email-boris.ostrovsky@oracle.com> <56743443.3070907@citrix.com> <5674446D02000078000C1630@prv-mh.provo.novell.com> <56743B8D.3070604@citrix.com> <56744C2502000078000C16E0@prv-mh.provo.novell.com> <56743F78.30609@citrix.com> <56744364.9000004@oracle.com> From: Andrew Cooper Message-ID: <56744416.8050507@citrix.com> Date: Fri, 18 Dec 2015 17:36:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.4.0 MIME-Version: 1.0 In-Reply-To: <56744364.9000004@oracle.com> X-DLP: MIA2 Cc: Daniel De Graaf , xen-devel@lists.xen.org, keir@xen.org, roger.pau@citrix.com Subject: Re: [Xen-devel] [PATCH v3] x86/HVM: Merge HVM and PVH hypercall tables X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 On 18/12/15 17:33, Boris Ostrovsky wrote: > On 12/18/2015 12:16 PM, Andrew Cooper wrote: >> On 18/12/15 17:10, Jan Beulich wrote: >>>>>> On 18.12.15 at 17:59, wrote: >>>> On 18/12/15 16:37, Jan Beulich wrote: >>>>>>>> On 18.12.15 at 17:28, wrote: >>>>>> On 17/12/15 23:00, Boris Ostrovsky wrote: >>>>>>> diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c >>>>>>> index a7767f8..871aca0 100644 >>>>>>> --- a/xen/arch/x86/mm.c >>>>>>> +++ b/xen/arch/x86/mm.c >>>>>>> @@ -3019,6 +3019,25 @@ long do_mmuext_op( >>>>>>> break; >>>>>>> } >>>>>>> + if ( has_hvm_container_domain(d) ) >>>>>>> + { >>>>>>> + switch ( op.cmd ) >>>>>>> + { >>>>>>> + case MMUEXT_PIN_L1_TABLE: >>>>>>> + case MMUEXT_PIN_L2_TABLE: >>>>>>> + case MMUEXT_PIN_L3_TABLE: >>>>>>> + case MMUEXT_PIN_L4_TABLE: >>>>>>> + case MMUEXT_UNPIN_TABLE: >>>>>>> + if ( is_control_domain(d) ) >>>>>>> + break; >>>>>> This needs to be an XSM check, rather than a dom0 check. >>>>>> Consider the >>>>>> usecase of a PVH/DMLite domain builder stubdomain. >>>>> But wouldn't that be the control domain then? Afaict by making this >>>>> an XSM check we'd also permit the hardware domain access to these, >>>>> for no reason. In fact we should probably further restrict this to >>>>> d != pg_owner. >>>> Any domain needing to construct PV domains needs to be able to make >>>> these hypercalls against the target domain. >>>> >>>> Therefore, the only valid check is whether XSM will permit >>>> 'current' to >>>> issue the hypercall against 'd', irrespective of whether current is >>>> the >>>> control domain, the hardware domain, or something else. >>>> >>>> I think all that is needed is xsm_mmuext_op(XSM_TARGET, d, pg_owner) >>> Which, as Boris has just pointed out, is already there. >> So it is. That is good. >> >>> But which also allows the d to issue such operations on itself. > > Won't get_pg_owner() fail in that case? (domid == curr->domain_id) test? > >> For safely sake, it is probably having either do_mmuext_op() or the XSM >> hook bail early if d is not a PV guest. >> >> I would hesitate at putting that check inside the hvm conditional at >> this point. > > I am not sure what you meant here. Something like this: (Completely untested) ~Andrew diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 92df36f..cc14905 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -2997,6 +2997,9 @@ long do_mmuext_op( if ( (pg_owner = get_pg_owner(foreigndom)) == NULL ) return -ESRCH; + if ( !is_pv_domain(pg_owner) ) + return -EINVAL; + rc = xsm_mmuext_op(XSM_TARGET, d, pg_owner); if ( rc ) {