Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BB23C4724C for ; Thu, 30 Apr 2020 14:33:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B004206D9 for ; Thu, 30 Apr 2020 14:33:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="eKkYZQCd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B004206D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jUAFo-0003aG-St; Thu, 30 Apr 2020 14:33:32 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jUAFn-0003Zz-Qa for xen-devel@lists.xenproject.org; Thu, 30 Apr 2020 14:33:31 +0000 X-Inumbo-ID: 8eeb9661-8aef-11ea-9a60-12813bfff9fa Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 8eeb9661-8aef-11ea-9a60-12813bfff9fa; Thu, 30 Apr 2020 14:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1588257209; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=5UfxOhG2UO9dRqqHimG4omLldKZGephHFunru/KJUz0=; b=eKkYZQCd3ClMslvdMpO9jRInpnDoKBGjH3vehC+ii3UAbigwzLZ++ABd 8JDGfqH1Jc0YH9+zvkFg21KF8CBq+7+n/OZytupumRz1NdnKx0d6z509J /eiqIfkwZpntLB4o5djgxyBzhLZ1SFOHqa7NeUHsc9hKgrjNdoNK3bZ4h E=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: jt56STdCNGd+x9LuHProSxsEaOrOVudPbxSuDBlZ1kXnNGTlCSGApQfXM1AVnJoYbLXOFOfwni 7eUhQoGby9YjqJi8HrbvVzk4YoMbrJiMBY+uVRL5GTQt/SPIAkjQgbuq0w6EzFJzqLydtFCsX8 YTx/5L1qsL7UlwMF9wYhOrET5DtLe9odKmaplmMSA5k1/psgAXHMP3TX8hFx+45/pujqizZTwu 6eHGN8q9Ay5cua+Jc/NAM+SwzrVYX7uc3K5NuXpFXz5942zNfJLIZj4de1+ZGOoh7/scC6Ev+4 CiM= X-SBRS: 2.7 X-MesageID: 16825940 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,336,1583211600"; d="scan'208";a="16825940" Date: Thu, 30 Apr 2020 16:33:21 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Subject: Re: [PATCH] x86/hvm: allow for more fine grained assisted flush Message-ID: <20200430143321.GE28601@Air-de-Roger> References: <20200430091725.80656-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <20200430091725.80656-1-roger.pau@citrix.com> X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Thu, Apr 30, 2020 at 11:17:25AM +0200, Roger Pau Monne wrote: > diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c > index 814b7020d8..1d41b6e2ea 100644 > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -4011,17 +4011,42 @@ static void hvm_s3_resume(struct domain *d) > } > } > > -static bool always_flush(void *ctxt, struct vcpu *v) > +static bool flush_check(void *mask, struct vcpu *v) > { > - return true; > + return mask ? test_bit(v->vcpu_id, (unsigned long *)mask) : true; > } > > -static int hvmop_flush_tlb_all(void) > +static int hvmop_flush_tlb(XEN_GUEST_HANDLE_PARAM(xen_hvm_flush_tlbs_t) uop) > { > + xen_hvm_flush_tlbs_t op; > + DECLARE_BITMAP(mask, HVM_MAX_VCPUS) = { }; > + bool valid_mask = false; > + > if ( !is_hvm_domain(current->domain) ) > return -EINVAL; > > - return paging_flush_tlb(always_flush, NULL) ? 0 : -ERESTART; > + if ( !guest_handle_is_null(uop) ) > + { > + if ( copy_from_guest(&op, uop, 1) ) > + return -EFAULT; > + > + /* > + * TODO: implement support for the other features present in > + * xen_hvm_flush_tlbs_t: flushing a specific virtual address and not > + * flushing global mappings. > + */ > + > + if ( op.mask_size > ARRAY_SIZE(mask) ) This should also check that the passed in flags are correct, ie: if ( op.mask_size > ARRAY_SIZE(mask) || (op.flags & ~(HVMOP_flush_global | HVMOP_flush_va_valid)) ) return -EINVAL; Roger.