From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 CE5BCC433E0 for ; Mon, 1 Feb 2021 13:01:44 +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 7793764DAE for ; Mon, 1 Feb 2021 13:01:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7793764DAE Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.79865.145561 (Exim 4.92) (envelope-from ) id 1l6Yph-00066C-7a; Mon, 01 Feb 2021 13:01:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 79865.145561; Mon, 01 Feb 2021 13:01:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l6Ypg-000663-W0; Mon, 01 Feb 2021 13:01:32 +0000 Received: by outflank-mailman (input) for mailman id 79865; Mon, 01 Feb 2021 13:01: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 1l6Ypf-00065x-P7 for xen-devel@lists.xenproject.org; Mon, 01 Feb 2021 13:01:31 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a9dd9674-1a73-480c-b1e5-e583ea8d4812; Mon, 01 Feb 2021 13:01:29 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a9dd9674-1a73-480c-b1e5-e583ea8d4812 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1612184489; h=subject:to:cc:references:from:message-id:date: in-reply-to:content-transfer-encoding:mime-version; bh=jV5KbZdyslnUG1RIxoDjF1hQa8y8ZFNzUwOz54zRj1k=; b=U0QEAvzzoioXPtw0GlZRTv2dAerUAQDQDiDTjQuKHe0zKWk0fD8ZWzoF ppZPNKJERa/inJwl4Ri7n/XQEbFsFUEY9AUxjdwEKPYrb5CProNuYmEzQ uBN5aMPpGjPPyw2v2cW9f1AUPGCjXyZTkFYW3c25npPDNfEfMi6CjzSrW 8=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: yAfHMaOzUlyVspQLwDXLD4V5TKdiDy4U4Trz1Pz1bcO3vtJUtJC6jpP6jLBOf8q8FnprQsNZkZ qvomp1IxyhyIgNyxzIpDrOuj222Ut1SmcTxZ2XRFfTLhLi91pam7JOwfXT+iVG2AKjELt37A6X Lo5Nz7P0sN/0xjmSVxqYyIIBBI1hd2kwGqYtuFW1GYkx+/J+Zlptyqkgzh0H3nzw/ZKtOSmPPr cixGBmYGLm7SGMEmIHOaYvMTzpX3ZJqUw0MMtGwOcpd/8s8ZJU0mWlXUyKCrX7fO89lYSujHYl BUQ= X-SBRS: 5.2 X-MesageID: 36650823 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.79,392,1602561600"; d="scan'208";a="36650823" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dgbK7UQYCjEsLTcKZ21s9QEnsRu+BLPv6ygoVD9Qf4hWaX0gPlDNk/zF/XaAYHyyY7bEi0UjT1LUnQuXjVc8tVbLB7bFqdacDPCnjZqT07jX00yXwhOxBY5ERzgPShTQ6UPjJsxMWAca22uPyoIhHsdTYH9eHNrTYlx7sLEIZXHHOgqo49yRnRVthmdUphFigYntPrN3u0JSSNwFOlh3kHsg8RHb5wqEvVDSy9TvytwOLoLhHa3/KLLrba8168S5exr8YReB79dTdaVKNbKck58MVnOI3IEIxkNZXhI3i8jtQrOMIcillg4t7kYQmr1xk+7hE1G5vALKJYOCS7OrPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jZp8HxNw9IQ8JWY9bpdc7k0Axvb7N23JXY6ItYc+ObE=; b=NZM9SdiQt0HhSRlkidDsZekPbc7ctyAKmnUYA+3gElx77pMFNb58jH8B/ZDE/lQ75b6Tf5ehnewaDc+pdsek8k7WZUOkRhJlOwFvO6uUyIA9P+gOG7S3qLUHNBuePmsNHd4ui5nlj2QSnyXPTvOWtRsSibSWa4U0mLO/tLD6yot1PxyBmM2fLxoCIttyBbHjHGXJluSjxQZZvTVusVpN2QlPlCOlp3lTLqLRdcCXLz6onSCin/CHZyC1X3J2msvlJ1CidsTN95bQPvfLpi/z55Psl9jp7pNqpZHV+UT4v0B6lAQPdrVIdjwMhSPG5rwycDchvV9K98tTnRq+LgrPIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jZp8HxNw9IQ8JWY9bpdc7k0Axvb7N23JXY6ItYc+ObE=; b=w7pAlCoHuC4DBdnFTZNGXWCeC1hD6+EWn/7AwqfpujZMSdNddfus4Ah6W4JNfVC14e4zpW1LI1Vt+7uHBU03rnwCG1dveqCAKFocXaCft4CcIwWEb18C3Y2zhFn+O5s2YIn+FRPLClQQAgS924YNTcdhIXJfof6zy43iPrnav90= Subject: Re: [PATCH v8 12/16] xen/domctl: Add XEN_DOMCTL_vmtrace_op To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= CC: Xen-devel , =?UTF-8?Q?Micha=c5=82_Leszczy=c5=84ski?= , "Jan Beulich" , Wei Liu , Jun Nakajima , Kevin Tian , Tamas K Lengyel References: <20210130025852.12430-1-andrew.cooper3@citrix.com> <20210130025852.12430-13-andrew.cooper3@citrix.com> From: Andrew Cooper Message-ID: <316b907e-ff40-039c-374a-c07fbb33bbc2@citrix.com> Date: Mon, 1 Feb 2021 13:00:47 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-GB X-ClientProxiedBy: LO2P265CA0516.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:13b::23) To BYAPR03MB4728.namprd03.prod.outlook.com (2603:10b6:a03:13a::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 93636516-10b3-4523-69b0-08d8c6b169b0 X-MS-TrafficTypeDiagnostic: BY5PR03MB5171: X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bkc6z/GuWbYNg0KO+2pS73gxt+kHyqYqAQTKsj1JMMaPvLa3UsirKIRW2AdxT1XFdHMQW1ehD3Uv4O2SWKoWDTFl5981UBsGRMurnKI4CTlnBB0Ro4Mjo/YxZ5q2qllRmnxYFp3CYgJgUOjhu69QUP8uVbuTHRqzKFCobG7Oa+c4saGLCzboWRP7wKyTbkocGDIGO58QrfQaUuTP7gT5N/hUnYnQ/n5A99VRh1NqREhOsVea/3Wt5PQPLI16edx8JdpEOsyRJG8psrU3p37HbxfVmbi3/AXwteQ+p2s71Zf5N8nW0KxXzNlgkYHMvT2Jf+JwDObXa/0rT0JF257jR2sAjbiNNcpXI3aqPif2gotJ5nVoNal5x/UNzmtM/cuseX+xdLXa79+GYGiDc89VlWIz/DwBMRa6EcEYksWV9MBluasOdpN60D3wb+UGX1ZuB2+D8AszXjclcxZts0kaV6U5q/Fm5hzGKQJiokgtnD8iid5RTf6blLjrPW4raBSnXDn3DBoOW0fOzmezKatGNjfN+DXRd7TIuXQOlYLTpytU7YsTtqtPne3imMyV5Xl+7rzKMJsACh5+CnHQfxVbHjuiA+eq4HpIDQlrfZgApJI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR03MB4728.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(86362001)(26005)(8936002)(16526019)(6862004)(956004)(2906002)(6636002)(4326008)(186003)(31696002)(5660300002)(478600001)(2616005)(66946007)(8676002)(66476007)(66556008)(53546011)(316002)(36756003)(54906003)(37006003)(31686004)(83380400001)(16576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UGZrV2tURnVCbXhnbVRT?= =?utf-8?B?c0VhTGl6Mm50ai9QU3AvODQrOEp3MnowUXNGNW42NTNKdHROSzAzamZ5UWJD?= =?utf-8?B?N0didTdWSEEyK1BSK0pZRjkrc0NIejE4NjZHZVZrbk9RY0Z0WThFTVNkdEwv?= =?utf-8?B?TVEvUktUSTJXRDF0dndad1hhZ1hjYmQxbTNkWHpKZWY2b1RqQStIaWU4YjNw?= =?utf-8?B?MkI5Y3hDdWNjaGovYnc5NW4rTm14YW1qdGg1SjQ1K0M0eVBXL0pxVDE2ZlZQ?= =?utf-8?B?d2EvUS9aTVE3WXlXRldGclh4VlJGck9iMVhYclFMNzNQM0EyL2Urc2RHZmVF?= =?utf-8?B?QW9PeThkeGdkSitMUllNVk9CMmRTWWtKeXZEczNIMzkwMDNwbm1ZMGlMZWRy?= =?utf-8?B?MStHN0lRQXVmR3dCMmF6R2FKSXNONi9YbCtTSmtjQnN6L1ZrdjNQRVcrU1gw?= =?utf-8?B?YzZCbXc2QVVDQVBJQ3N0UFN2WS9tbXAveHdLbjVJZ3A0Y0EydkxrOVlMZW9Y?= =?utf-8?B?WWR5YTNGbFNZLy8wRHh4c216WHJqNy8zTGMyRlZKay9sOWs5TlpCVkNnN1RJ?= =?utf-8?B?RmtCcDg2aXdhdGpJS1dTd0V3QkJMZUgranZsNzBRQUNtZmhlaUhlV0MvaGFN?= =?utf-8?Q?PN3oYw9K?= X-MS-Exchange-CrossTenant-Network-Message-Id: 93636516-10b3-4523-69b0-08d8c6b169b0 X-MS-Exchange-CrossTenant-AuthSource: BYAPR03MB4728.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2021 13:00:56.0403 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fCNhi+F8EzbknVlpDZary7v8qn347XdzFQRP7FFgGPzN7zXYkuQfdNC+kLo6tUkY9/HhKvEK5IZuhHqqLB+QG/wa43epeua8Dv/Lecq5aHY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR03MB5171 X-OriginatorOrg: citrix.com On 01/02/2021 12:01, Roger Pau Monné wrote: > On Sat, Jan 30, 2021 at 02:58:48AM +0000, Andrew Cooper wrote: >> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c >> index 12b961113e..a64c4e4177 100644 >> --- a/xen/arch/x86/hvm/vmx/vmx.c >> +++ b/xen/arch/x86/hvm/vmx/vmx.c >> @@ -2261,6 +2261,157 @@ static bool vmx_get_pending_event(struct vcpu *v, struct x86_event *info) >> return true; >> } >> >> +/* >> + * We only let vmtrace agents see and modify a subset of bits in MSR_RTIT_CTL. >> + * These all pertain to data-emitted into the trace buffer(s). Must not >> + * include controls pertaining to the structure/position of the trace >> + * buffer(s). >> + */ >> +#define RTIT_CTL_MASK \ >> + (RTIT_CTL_TRACE_EN | RTIT_CTL_OS | RTIT_CTL_USR | RTIT_CTL_TSC_EN | \ >> + RTIT_CTL_DIS_RETC | RTIT_CTL_BRANCH_EN) >> + >> +/* >> + * Status bits restricted to the first-gen subset (i.e. no further CPUID >> + * requirements.) >> + */ >> +#define RTIT_STATUS_MASK \ >> + (RTIT_STATUS_FILTER_EN | RTIT_STATUS_CONTEXT_EN | RTIT_STATUS_TRIGGER_EN | \ >> + RTIT_STATUS_ERROR | RTIT_STATUS_STOPPED) >> + >> +static int vmtrace_get_option(struct vcpu *v, uint64_t key, uint64_t *output) >> +{ >> + const struct vcpu_msrs *msrs = v->arch.msrs; >> + >> + switch ( key ) >> + { >> + case MSR_RTIT_OUTPUT_MASK: > Is there any value in returning the raw value of this MSR instead of > just using XEN_DOMCTL_vmtrace_output_position? Yes, but for interface reasons. There are deliberately some common interfaces (for the subset of options expected to be useful), and some platform-specific ones (because there's no possible way we encode all of the options in some "common" interface). Yes - there is some overlap between the two sets - that is unavoidable IMO.  A user of this interface already needs platform specific knowledge because it has to interpret the contents of the trace buffer. Future extensions to this interface would be setting up the CR3 filter and range filters, which definitely shouldn't be common, and can be added without new subops in the current model. > The size of the buffer should be known to user-space, and then setting > the offset could be done by adding a XEN_DOMCTL_vmtrace_set_output_position? > > Also the contents of this MSR depend on whether ToPA mode is used, and > that's not under the control of the guest. So if Xen is switched to > use ToPA mode at some point the value of this MSR might not be what a > user of the interface expects. > > From an interface PoV it might be better to offer: > > XEN_DOMCTL_vmtrace_get_limit > XEN_DOMCTL_vmtrace_get_output_position > XEN_DOMCTL_vmtrace_set_output_position > > IMO, as that would be compatible with ToPA if we ever switch to it. ToPA is definitely more complicated.  We'd need to stitch the disparate buffers back together into one logical view, at which point get_output_position becomes more complicated. As for set_output_position, that's not useful.  You either want to keep the position as-is, or reset back to 0, hence having a platform-neutral reset option. However, based on this reasoning, I think I should drop access to MSR_RTIT_OUTPUT_MASK entirely.  Neither half is useful for userspace to access in a platforms-specific way, and disallowing access entirely will simplify adding ToPA support in the future. ~Andrew