From patchwork Wed Apr 22 19:57:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael Kelley (LINUX)" X-Patchwork-Id: 11504451 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 311111667 for ; Wed, 22 Apr 2020 19:58:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1480D215A4 for ; Wed, 22 Apr 2020 19:58:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b="V/MEbOp3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726380AbgDVT6n (ORCPT ); Wed, 22 Apr 2020 15:58:43 -0400 Received: from mail-dm6nam11on2109.outbound.protection.outlook.com ([40.107.223.109]:6625 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726158AbgDVT6k (ORCPT ); Wed, 22 Apr 2020 15:58:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bBJ5CZQylruQAwGp8NGTYYw+gZxG72j2Mzstn7f30fO5wIFTaxxbHl6iFmHItSI6X60UYUKzuJpTer5eLmEoQYisbIZ4sZELMjgh48EhtqEEq8v1EalvK77xoUuK6BHqAVFqJQGKZ7fOLqdYI+X3bEzHkDdxJ52zfg6FFS09WQtWr/k2imV75QlnyVeikYfzqAXFtAZEIl82KazBn5BWY1IjKTs6uWT7uAKHK5pS3x1eUBa6Rv0qF6kGmY1hPXsn5uKXCROYrGEar+M1Zrs9UwyTlx80oeQtgyZ2fvdrUgCAp0xG0AICNynYItyA7aq6Q9kTG8tDK4SncCtF7q80vQ== 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=kZCGC1hl4qYHX9P4nKjkybcUPVyLM/057OCoaFiqEFM=; b=LrtjQhdKL74FlxtViBs5G9gZ3E6FdYe7sVRL2VDtL0CjDDOE+VFO/Mbw2/ha4z4V6MRImlb0Hbnaccy5JEAZFV0Lzqh0g+/+QaetRPYeZxtlW7GjVHagL8KKAbyNvrzTVCGgLmlfMi61r0x9oYb+aV+vegXuoRG6sokYnM6CrvSQ5Qm38e7iEn1GG3XonaeIneB7rPNs3waDT7SOuziWHGYOVV18AzBIiiuuTgagBt3BDBS6jcCO54j+N8bJkub7KWCyzsAi1Zd/j76aWTRS27icHDt72aDjIl7ULDrBqdzACjhzEiLyNWa01HFpV+vsOO82Git7wiiJMFI5sjy6jA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kZCGC1hl4qYHX9P4nKjkybcUPVyLM/057OCoaFiqEFM=; b=V/MEbOp35JygXGtbq6RQR2e7vd8mRQHOYMLEhp5CUtZkYBChsvFJsWMGJ9HlsjIycuHfXqxmr4nW6B8m/40LCBD5p2u9ptGgCz2j74vafp2sJKSs/1iooMerJ6LE1gdkliniMh55XhzK1QpYaWXp8mopIlkAi2qC3MgWVMoh1b4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=mikelley@microsoft.com; Received: from BN6PR21MB0178.namprd21.prod.outlook.com (2603:10b6:404:94::12) by BN6PR21MB0148.namprd21.prod.outlook.com (2603:10b6:404:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.2; Wed, 22 Apr 2020 19:58:37 +0000 Received: from BN6PR21MB0178.namprd21.prod.outlook.com ([fe80::a97c:360c:9ed2:12ec]) by BN6PR21MB0178.namprd21.prod.outlook.com ([fe80::a97c:360c:9ed2:12ec%11]) with mapi id 15.20.2958.001; Wed, 22 Apr 2020 19:58:37 +0000 From: Michael Kelley To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, pbonzini@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Cc: mikelley@microsoft.com Subject: [PATCH v2 1/4] KVM: x86: hyperv: Remove duplicate definitions of Reference TSC Page Date: Wed, 22 Apr 2020 12:57:34 -0700 Message-Id: <20200422195737.10223-2-mikelley@microsoft.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200422195737.10223-1-mikelley@microsoft.com> References: <20200422195737.10223-1-mikelley@microsoft.com> X-ClientProxiedBy: MWHPR19CA0078.namprd19.prod.outlook.com (2603:10b6:320:1f::16) To BN6PR21MB0178.namprd21.prod.outlook.com (2603:10b6:404:94::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from MHKdev.corp.microsoft.com (167.220.2.108) by MWHPR19CA0078.namprd19.prod.outlook.com (2603:10b6:320:1f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13 via Frontend Transport; Wed, 22 Apr 2020 19:58:35 +0000 X-Mailer: git-send-email 2.18.2 X-Originating-IP: [167.220.2.108] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 218d2491-aac4-47da-3a51-08d7e6f78b83 X-MS-TrafficTypeDiagnostic: BN6PR21MB0148:|BN6PR21MB0148:|BN6PR21MB0148: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 03818C953D X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR21MB0178.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(136003)(396003)(366004)(376002)(39860400002)(81156014)(82960400001)(8936002)(10290500003)(4326008)(26005)(82950400001)(5660300002)(107886003)(956004)(2616005)(478600001)(66556008)(66946007)(66476007)(6486002)(1076003)(86362001)(316002)(8676002)(2906002)(16526019)(186003)(36756003)(52116002)(7696005)(7416002)(921003);DIR:OUT;SFP:1102; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1752yKqdsvkH1CkUQFwigt3CYVjSx8FN00WL1VNxyLtGhAsJg5+Dqs5zvPd+SDFY/B3DNv1tqXb9PDkRIEhliseTqqBwCM42yrfrw02F7WNc6/gZh1Cp8oVVOcLU+BU+qloYDYGBA7xFAxNGIRjGNI1o/CYY1wKxTI3dANSNuzqULsdhCv0uTFTSo9h2ENqzFBUVF/xv1XIFzqHR9zZHpCfQPKCB6A6JomHYPHDO4GUuzK/eNJ6jph9eQxbRAdEiIvLD/R7DOWN1Z/G0amLWcgaL6mBcH7cIn0C9Hrh0g57LDvdnGVnV7D6apD8V+9ixEAhYpGkVO23kroHFX/F3xskEA8SsRBMezg2N7+LrwIjPO0lXtqMaRdFi4AQsHReZb/4281+sGGEHVKk08mSzi2lTsEI7ypQVMiPsitZ//wkupOwxbgdgg+HjXItBk2qX7zNo3Wdx8Qet/ntjU0AhDpPn8trJM63RrB7PD8LLrL4= X-MS-Exchange-AntiSpam-MessageData: bz3U0syiuvEFTKQRnFLQwCoWB17AXxgkGadfo/mOKaox2WFIdMGRQtJZxe8kn+QvNQU/YkoTMLadt27wPRBbfZwintCC8h1/qToN32IInDqqZPJ59S9DcHAhyPKcfCdRWlnPDbSwrEiSdddTq2nFfRUNFvmfcShCai0/jW+lDDjkDHAAvZNupCpAOCom/iKjJpSVDhhCsHR/ZtKdaKdKara1rhzeEqpsPMAQpMOF9+rQGS1kUs/JEHmtMDu3aO71I+0XVoxXV4r7BEPjBCxZBDUFL6MCB75BgiQLsdd+4BQyoKHmjN/snddVZ01BzQsxqs5aKr9IFgo/ZrTgODaFdB2cHSX8N2cboeHBXwVDg4AU8ERBb8Di3LclyhyNzeIyGITc1RWH8N0Fqr/0yrjgVWS+AHVNbEGWbLyOk/NDc2liijgynI1Ey0c2vYOO88cjgSf+h9dQdLQp2vdSRA8dVx3mxRdfmJTVaiZcSMyqpNJ7PHgklZ8gCMBKeIAueei3rWUi5SXc0L9gSBZHlJspvnv1BO2jY0Qas8Y+BEDXlq+qSCkVQ+4v8Ff1AddzGFyizShuM1euO6gOMJZkPiD/Uf3m6c9/V/vjza47FEL3YpjnOsxwZvNTOjgdotr5XS7TcOYoHwMpG9hrylSF0YLzL2Gk2KicLZalNcp4HpyibK5FanCrqlzGW57ACem1V8vDLczdE+eKndaEnMd5w/YFd3OLyBYnQA2uR3nUge8aZLoF9t+nABym9uu4EdYLZK7XdDPL0vxZMaLvuJigSgI/9PfXz+HseNzA8+HftfMSBR0= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 218d2491-aac4-47da-3a51-08d7e6f78b83 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2020 19:58:36.9637 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EN0LugPXZvgmDhV1VLl6zf4D4qpOxn5F9PD/jOU3dR5nyBdBWbW62pO5ONTW+HeWZE3yVp8BGxoZu0LyYfQyzg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR21MB0148 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The Hyper-V Reference TSC Page structure is defined twice. struct ms_hyperv_tsc_page has padding out to a full 4 Kbyte page size. But the padding is not needed because the declaration includes a union with HV_HYP_PAGE_SIZE. KVM uses the second definition, which is struct _HV_REFERENCE_TSC_PAGE, because it does not have the padding. Fix the duplication by removing the padding from ms_hyperv_tsc_page. Fix up the KVM code to use it. Remove the no longer used struct _HV_REFERENCE_TSC_PAGE. There is no functional change. Signed-off-by: Michael Kelley Reviewed-by: Vitaly Kuznetsov --- arch/x86/include/asm/hyperv-tlfs.h | 8 -------- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/hyperv.c | 4 ++-- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index 29336574d0bc..0e4d76920957 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -303,7 +303,6 @@ struct ms_hyperv_tsc_page { u32 reserved1; volatile u64 tsc_scale; volatile s64 tsc_offset; - u64 reserved2[509]; } __packed; /* @@ -433,13 +432,6 @@ enum HV_GENERIC_SET_FORMAT { */ #define HV_CLOCK_HZ (NSEC_PER_SEC/100) -typedef struct _HV_REFERENCE_TSC_PAGE { - __u32 tsc_sequence; - __u32 res1; - __u64 tsc_scale; - __s64 tsc_offset; -} __packed HV_REFERENCE_TSC_PAGE, *PHV_REFERENCE_TSC_PAGE; - /* Define the number of synthetic interrupt sources. */ #define HV_SYNIC_SINT_COUNT (16) /* Define the expected SynIC version. */ diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 42a2d0d3984a..4698343b9a05 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -865,7 +865,7 @@ struct kvm_hv { u64 hv_crash_param[HV_X64_MSR_CRASH_PARAMS]; u64 hv_crash_ctl; - HV_REFERENCE_TSC_PAGE tsc_ref; + struct ms_hyperv_tsc_page tsc_ref; struct idr conn_to_evt; diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index bcefa9d4e57e..1f3c6fd3cdaa 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -900,7 +900,7 @@ static int kvm_hv_msr_set_crash_data(struct kvm_vcpu *vcpu, * These two equivalencies are implemented in this function. */ static bool compute_tsc_page_parameters(struct pvclock_vcpu_time_info *hv_clock, - HV_REFERENCE_TSC_PAGE *tsc_ref) + struct ms_hyperv_tsc_page *tsc_ref) { u64 max_mul; @@ -941,7 +941,7 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm, u64 gfn; BUILD_BUG_ON(sizeof(tsc_seq) != sizeof(hv->tsc_ref.tsc_sequence)); - BUILD_BUG_ON(offsetof(HV_REFERENCE_TSC_PAGE, tsc_sequence) != 0); + BUILD_BUG_ON(offsetof(struct ms_hyperv_tsc_page, tsc_sequence) != 0); if (!(hv->hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE)) return; From patchwork Wed Apr 22 19:57:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael Kelley (LINUX)" X-Patchwork-Id: 11504453 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00B3B14DD for ; Wed, 22 Apr 2020 19:58:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D672A20882 for ; Wed, 22 Apr 2020 19:58:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b="WZ+9TqWh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726797AbgDVT6r (ORCPT ); Wed, 22 Apr 2020 15:58:47 -0400 Received: from mail-dm6nam11on2109.outbound.protection.outlook.com ([40.107.223.109]:6625 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726614AbgDVT6n (ORCPT ); Wed, 22 Apr 2020 15:58:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MaBstzPorftb2bgOinzvOEHMqIcGFP0dxKuVjUeY4kaicDPjV6vUsVhPvdknQGXLAEEpnvVvOT7tcGKFkQztNWOvY+nSTN43xzlKQZOH9jGi8YQRQKfVkZAjHsizBgd0RYFAIT7x/2IniwAnveKonQHrOhvZ+rC34fQ/78BN7Txm6krAwwYF4TlKPPBUG923aHmo/Kvad4/9B+wQYrNbqrPjfmwfqLQT4GGatQ9UVBI9wOYbF9elgxBnQVWAaZ2eTiQQCfK9YHvTmnjyED9/Wk4CsqffybfFS7p7maB0lFd/S0STIXjdf8mEBxfi+315AaRTsTyTM+AzrZQV6mjD7g== 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=n+FJPRWCBME3O7KGGef1+PrqQRgqyoCRq2kHsgRrvy0=; b=OViH1NholJnQ6J3g2laPWvVGos64a+PMyzQiuaSXTbF9E+PS8Ef8EOFZU8GajpPDT+t+e3SWVJPBpwhNqUGTvw/Vk8wgQ3HQAcVdE0Ue6qjXPAvG1hRPagNrKIvGjitO4UgamfXxas+rVtBn+0k+8UzCrhdqQy7efPbrToVMyOsX2v0m7kKhwWiwRPOBoiHocUMmEe3rBipE+1siPCI3UUr4FBLa1sBc6tFntR4Hk0+7Mt46rFxyr49hh32mr4eei+M8BXOIZdy3OHE/6NEZriIbB89B2LbkhTa2MWBqdiMfxQCEjjv2AF0tS7PqwGNmzf8RHF7LVZl3xsSXBdemjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n+FJPRWCBME3O7KGGef1+PrqQRgqyoCRq2kHsgRrvy0=; b=WZ+9TqWh5iLKdfwNDDa0VY9CzqqQu2HCKPx68jWAfDAtoSXZUeXDnj1AmPa1w71ir7yT3nDtdaooIGVQo18+19o3tiQlbU+Uu1JibJYfJ0s3sD928Tuczz2OnFjplUlkD/KEuJSrnbGv9bnc94jJgmsujsXyA+CdEOL1QyTeSbQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=mikelley@microsoft.com; Received: from BN6PR21MB0178.namprd21.prod.outlook.com (2603:10b6:404:94::12) by BN6PR21MB0148.namprd21.prod.outlook.com (2603:10b6:404:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.2; Wed, 22 Apr 2020 19:58:39 +0000 Received: from BN6PR21MB0178.namprd21.prod.outlook.com ([fe80::a97c:360c:9ed2:12ec]) by BN6PR21MB0178.namprd21.prod.outlook.com ([fe80::a97c:360c:9ed2:12ec%11]) with mapi id 15.20.2958.001; Wed, 22 Apr 2020 19:58:39 +0000 From: Michael Kelley To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, pbonzini@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Cc: mikelley@microsoft.com Subject: [PATCH v2 2/4] x86/hyperv: Remove HV_PROCESSOR_POWER_STATE #defines Date: Wed, 22 Apr 2020 12:57:35 -0700 Message-Id: <20200422195737.10223-3-mikelley@microsoft.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200422195737.10223-1-mikelley@microsoft.com> References: <20200422195737.10223-1-mikelley@microsoft.com> X-ClientProxiedBy: MWHPR19CA0078.namprd19.prod.outlook.com (2603:10b6:320:1f::16) To BN6PR21MB0178.namprd21.prod.outlook.com (2603:10b6:404:94::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from MHKdev.corp.microsoft.com (167.220.2.108) by MWHPR19CA0078.namprd19.prod.outlook.com (2603:10b6:320:1f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13 via Frontend Transport; Wed, 22 Apr 2020 19:58:37 +0000 X-Mailer: git-send-email 2.18.2 X-Originating-IP: [167.220.2.108] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: faeddb51-14cd-4b52-a020-08d7e6f78cae X-MS-TrafficTypeDiagnostic: BN6PR21MB0148:|BN6PR21MB0148:|BN6PR21MB0148: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-Forefront-PRVS: 03818C953D X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR21MB0178.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(136003)(396003)(366004)(376002)(39860400002)(81156014)(4744005)(82960400001)(8936002)(10290500003)(4326008)(26005)(82950400001)(5660300002)(107886003)(956004)(2616005)(478600001)(66556008)(66946007)(66476007)(6486002)(1076003)(86362001)(316002)(8676002)(2906002)(16526019)(186003)(36756003)(52116002)(7696005)(7416002)(921003);DIR:OUT;SFP:1102; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZfpH65vkbUJUkcLcCmnMOJZy1zaniR8HEP+S09WBjvA94vHnbkFmMMsq7nxVN1ra45tS4dr69a2q6qjlkpTfCpFaLQXbXpB1Gx0L561JNWDWEgQ8e3pprnxYRmUrNtLVqIWfNaRZUbjgbzPdoL3flSzeb/onjN3S0xtrvsklXAokvXhgMp5yl6+VnzpEFTPRWBj63OT9dUtmtpXEx74hsV5Ehs/NgvLlNp4NtQFKq3uY6xzEW2ZIsOUxFdP+tBABHkWAQsWND5YQDvzYn7cIVug9lR/jDGMuzljD3phEeT76CTbQrtTsHEClt9pd/aay7ChmL7UBUBks0xkAT+gVe5kT+6NnNlYh2aJgZ+5GZJALt+LrOGZuTMDFZSY0NqBtgR07KGbw+GhajFyQa6arAQIQ7qIcsMUV4au3TzYPV2qISP+iI2UY1AO7I8Y07mH409eb2WajkPx9gBJxfP7QdxRqWV/ZIVbHoaWklEZyIC0= X-MS-Exchange-AntiSpam-MessageData: lDSC7PleaF76tOUwyXCfrD3cd10HEJLKXkpZuzb3TCPujvHDefvEm1BE8ScbwCKvgvBXBRD0RGuS3YNzIJVInzyJGmb+YObkRODnZTFf1k4Qa2/sbwSBwlrtySTVpDMs4FTv8JQK/jx9YjIRileQqduL5WAXvH0eKgiM3sDcVPUQ31SADCdVWfTVDxjQUcRVfJsipTmabiFIVofB7NXW/2ml2Y4gVLliWCYcLXKQ0XTrgsruSLWs4KUaxHLwHXVj/vAu8qwOGAdzZcaqek0xXOlo9ZjhB5nSwiNwLHR5qviOUOHLrlFwT6c9ZOXEZqtc9Esd7foYXoclF2xEKHr3Y4sfWFDEEcEK9fitWdvq5t0doaXJsKedLq7aBAiZjGpVwgJRWLPJc9IRR64KDj3A/9UOoxiuFGPeTuWgA2hqhP1XFtttjrMH3h4W7AtTeK/ul+84twaEp7r974PHhA10fvriRNlkZq0wh7D+An001Kk/VNOmiQkG6lXRTqwT+1CQIxucG+YcRaZ67XBFoxFDtma6YJe7PaVvxhsubNt/RH9EHWgasLQmjEJ8ALfkQO/3afVW6y7XkWwqyk52/xwUgqDXqjNRIpLb7wLSzrrsyaLiavpoa/dyTR3BT62XHHe2VC2iy2GdfSGRcMWwtt+hs9BzWe3+8Sqit7fYzPGnBOOYoZUeuUcd3Hyn7v0CwDDkGS9cUaRGsBcI0Vttt8RA+KN0tyPpKQLwijbl5+nipkHDQfSlcURkELdKdwfFoBKsRHQhIi2eEfTKOuZn47zfCXxqKK9KYg+zCq0jKzspeWE= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: faeddb51-14cd-4b52-a020-08d7e6f78cae X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2020 19:58:39.0178 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /6CzrFE0xqg2sz+sepssepYIefG8jsQAhMhjRHokGwHxx9MbT1RNCWMgf05syWATnYtrETg+NWlMZWL9Su/blA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR21MB0148 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The HV_PROCESSOR_POWER_STATE_C #defines date back to year 2010, but they are not in the TLFS v6.0 document and are not used anywhere in Linux. Remove them. Signed-off-by: Michael Kelley --- arch/x86/include/asm/hyperv-tlfs.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index 0e4d76920957..2dd1ceb2bcf8 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -390,11 +390,6 @@ struct hv_tsc_emulation_status { #define HV_X64_MSR_TSC_REFERENCE_ENABLE 0x00000001 #define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT 12 -#define HV_PROCESSOR_POWER_STATE_C0 0 -#define HV_PROCESSOR_POWER_STATE_C1 1 -#define HV_PROCESSOR_POWER_STATE_C2 2 -#define HV_PROCESSOR_POWER_STATE_C3 3 - #define HV_FLUSH_ALL_PROCESSORS BIT(0) #define HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES BIT(1) #define HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY BIT(2) From patchwork Wed Apr 22 19:57:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael Kelley (LINUX)" X-Patchwork-Id: 11504457 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78716159A for ; Wed, 22 Apr 2020 19:59:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4ACDD2077D for ; Wed, 22 Apr 2020 19:59:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b="Sn1uiQxE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbgDVT6w (ORCPT ); Wed, 22 Apr 2020 15:58:52 -0400 Received: from mail-dm6nam11on2109.outbound.protection.outlook.com ([40.107.223.109]:6625 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726081AbgDVT6v (ORCPT ); Wed, 22 Apr 2020 15:58:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GlIKiskk8SS66cGJ8z3OxLjZZzaRK/zjJ746t3/7D3DUTVs/Oa6cc2cghJyRsEWkiFTJr53wGP0wB3vhTfYYbHMpkMMguRqhDTAwy+TpiLq2iJpr/N8us0StDAwc9hocSwbDvIgcIl3lY5Mym/RCKuHqZDqYvYvwRVwG4kIkearN0fCHJT0/MdC1iFDkzLOd/NY5sBee1+2Syoxm7NhH+JI0vPyTLfai+5abV/lZc7zYc5+C0Yw/XdNSeM6FwzBVVC8IhxwwX+3xeZYxxTmEfTUVS8oYt7V8ZjoTnWITcYGpRB9Aw6oKFFP7vbjhdDR+P6d7VOpMCVVbc+3Q4rs9gQ== 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=i9QFoDcGbXAJY4hyYeLPKl5ZurXv/z9F3MLBdlkXUes=; b=MuQn0mFedpC5WAKoM/5FesOzFpbaTmY3DZTVa6aY/ABEqtewbHnbgllsru98sGyhUj8crJl/HvWr1QyuTnnNuRfb8WRFPKQWKIX86KbBSKHHnpYpKMpjyqPMXsmki9qqd13Sy4FQkAs+FZrLzmIs2NzQpMcJCnrACQHtwqihE2daOvLkPvEyfQfExf4kRfpOUze1OUw3XWXBZanvWUxEir1oT+0pz/HuFZmvZaoWkKLoUDPSyJ83pYOUvKtsWqNEC/OyjXd1xdQ5Av1WU6Lxq+wPwFLPWsmA0hQLo8mv/YlXvuS3mVTy5PZKd0I9qdBlBjnQqWPQuvcd5kjTypJnAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i9QFoDcGbXAJY4hyYeLPKl5ZurXv/z9F3MLBdlkXUes=; b=Sn1uiQxENIwkENEv6KN3+M6fKYFUrswd7eEC60isCE3EmbrlxB+MoS+7fhBE6Ifk5GvMz3BoewT9BhBIs+lA4XHvQYTPFNur7pH9gaEFp8JxxqoLQsa4XOdhRfr7dR99zWwcaOmsRxhI+jIwcqwfCa6niorKejce+onui7mHQOc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=mikelley@microsoft.com; Received: from BN6PR21MB0178.namprd21.prod.outlook.com (2603:10b6:404:94::12) by BN6PR21MB0148.namprd21.prod.outlook.com (2603:10b6:404:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.2; Wed, 22 Apr 2020 19:58:41 +0000 Received: from BN6PR21MB0178.namprd21.prod.outlook.com ([fe80::a97c:360c:9ed2:12ec]) by BN6PR21MB0178.namprd21.prod.outlook.com ([fe80::a97c:360c:9ed2:12ec%11]) with mapi id 15.20.2958.001; Wed, 22 Apr 2020 19:58:41 +0000 From: Michael Kelley To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, pbonzini@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Cc: mikelley@microsoft.com Subject: [PATCH v2 3/4] x86/hyperv: Split hyperv-tlfs.h into arch dependent and independent files Date: Wed, 22 Apr 2020 12:57:36 -0700 Message-Id: <20200422195737.10223-4-mikelley@microsoft.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200422195737.10223-1-mikelley@microsoft.com> References: <20200422195737.10223-1-mikelley@microsoft.com> X-ClientProxiedBy: MWHPR19CA0078.namprd19.prod.outlook.com (2603:10b6:320:1f::16) To BN6PR21MB0178.namprd21.prod.outlook.com (2603:10b6:404:94::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from MHKdev.corp.microsoft.com (167.220.2.108) by MWHPR19CA0078.namprd19.prod.outlook.com (2603:10b6:320:1f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13 via Frontend Transport; Wed, 22 Apr 2020 19:58:39 +0000 X-Mailer: git-send-email 2.18.2 X-Originating-IP: [167.220.2.108] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 30fb60d5-85a6-45ab-169a-08d7e6f78ded X-MS-TrafficTypeDiagnostic: BN6PR21MB0148:|BN6PR21MB0148:|BN6PR21MB0148: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 03818C953D X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR21MB0178.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(136003)(396003)(366004)(376002)(39860400002)(81156014)(82960400001)(8936002)(10290500003)(4326008)(966005)(26005)(82950400001)(5660300002)(107886003)(956004)(2616005)(478600001)(66556008)(66946007)(66476007)(6486002)(1076003)(86362001)(6666004)(30864003)(316002)(8676002)(2906002)(16526019)(186003)(36756003)(52116002)(7696005)(7416002)(921003);DIR:OUT;SFP:1102; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VgKRJuujertbtjeIVCfNgnJvLa1Bps1m+NaKjH0+i823ZfqAoRD18krOekuLTHpvI4EOjMQT43nvzfu906WW9Q2IyWel6vfrhB7qj5znEYDtZInO0SqhNsbyBvz542xkMGMAmpyGbdC+i+KQVxwKDZOvIohszfAuuPqDrnF3kNJtfbSsGWd49FTN3oh0TD6e5dh7ijeV5diD+z0vxVZHY8b4Q2ZqU6UlwclPDuIs/KX5pglf/6nFYah+zb/DDYHXKidmCWvADf0aNrv2fktzPsxuLpyn8vON7BX9nPUvCuwewgFerKpZ6iRGatLvdBTafpssusapo6CQbcFWrQWB839RR8dA6DrFjo8VXb+W9NNIRsSCN9fVZEHPfy721K4PARhZpyMzSu1Z7tBAqYr8DLhRiFc7EKMIFMi+S/N3FF9LDLir5kjS3Ql6u9iTKreWf96YzT8XLHbtHya3BM6QaQ5pboPbn40UodPOzPndb2Ii5JANu+DuKozv8MAq5ojLolJiIkZ96ffynv/uzfmKugkGyWOXNdjb45gXK00vCcvRqKaGB2mXcvNGg78sXhsl X-MS-Exchange-AntiSpam-MessageData: L50PzPYlh+DLHj1hvJCUP0JjzS67S+IVNPR9XPkUBCCffqgREVVWBiVixnMlZH+8VhMYawW39GZBeVXRytoJBQU11MTFj+VM16YTBSmwsP84nnYiZatlwqCxX43/N3CnpAMqWyVYMgOetrxhA3cZuxKs0f6BjX6Cl6cRDFmsJVjtmvcW5JRkA0frWEUv6PKEt5jdHiL/Osc7kE+oBKsGbhj7YCfEnLvbP6kxYY3+czezWjQD1YaderZWP/H65jtJbcxq3tGIYweXWF4Zr5RSTMQvhnM3Ia0PukY5K8+pZsdeZI67VQze3KOR/5fhuThRZ1VdGjwXxmCFaCAytZBweDLMd71C/Xfvy0fC3Q15cfkSee2Mc0DBvDhV0ud6K4m7V4TTkzIz8k4E/HhfuEfiru/XBjp3m68NeeWTQ00+sXGqqqgh78HsG2KW7eQRjGv5SWsEgrz5Scszu8jc0IZh2QK4To601boAGZd59EA5hBCcECbqG+ST8UzMOJ+/Um4WAoBgLfYUtZUnc1WQae5ft3baMO0HDzXirwrBpsFwYM66kgvBjty0u8a/RRnyonKBCcgKOj/kqTg+w2d+fnz/ruYGGDMWLSpPsRIHp/XLS9fhunbXk0pv7d6bl+H+p0Ki2bhjb7zIemoq62Xh8BfhiqHczg4C9j02qB6VUqUszlmDK6froXFbxp1+/YHiSxvV1ojrO45O1blcwRgeOkWWLAISA8QYc18R8MR9UL2e5jmVJcz9beesT5OGdRdiElXlzcXwL30hI7D8VH8x8KJUVEaiH6Oc8I4gHk5T8AeYb1U= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30fb60d5-85a6-45ab-169a-08d7e6f78ded X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2020 19:58:41.1319 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: i+OZ+s6c1AV7ffW6Xz5UP0QJp2yaTjSEhaSsHwwWOP0QWbKSavsAYlbvJsxnHd+IYWpiiMrMf7b3OZC3rnbAjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR21MB0148 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In preparation for adding ARM64 support, split hyperv-tlfs.h into architecture dependent and architecture independent files, similar to what has been done with mshyperv.h. Move architecture independent definitions into include/asm-generic/hyperv-tlfs.h. The split will avoid duplicating significant lines of code in the ARM64 version of hyperv-tlfs.h. The split has no functional impact. Some of the common definitions have "X64" in the symbol name. Change these to remove the "X64" in the architecture independent version of hyperv-tlfs.h, but add aliases with the "X64" in the x86 version so that x86 code will continue to compile. A later patch set will change all the references and allow removal of the aliases. Signed-off-by: Michael Kelley --- MAINTAINERS | 1 + arch/x86/include/asm/hyperv-tlfs.h | 459 +++-------------------------- include/asm-generic/hyperv-tlfs.h | 442 +++++++++++++++++++++++++++ 3 files changed, 479 insertions(+), 423 deletions(-) create mode 100644 include/asm-generic/hyperv-tlfs.h diff --git a/MAINTAINERS b/MAINTAINERS index cb68a9437eff..843f2f30648f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7884,6 +7884,7 @@ F: drivers/pci/controller/pci-hyperv.c F: drivers/scsi/storvsc_drv.c F: drivers/uio/uio_hv_generic.c F: drivers/video/fbdev/hyperv_fb.c +F: include/asm-generic/hyperv-tlfs.h F: include/asm-generic/mshyperv.h F: include/clocksource/hyperv_timer.h F: include/linux/hyperv.h diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index 2dd1ceb2bcf8..4e91f6118d5d 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -11,17 +11,6 @@ #include #include - -/* - * While not explicitly listed in the TLFS, Hyper-V always runs with a page size - * of 4096. These definitions are used when communicating with Hyper-V using - * guest physical pages and guest physical page addresses, since the guest page - * size may not be 4096 on all architectures. - */ -#define HV_HYP_PAGE_SHIFT 12 -#define HV_HYP_PAGE_SIZE BIT(HV_HYP_PAGE_SHIFT) -#define HV_HYP_PAGE_MASK (~(HV_HYP_PAGE_SIZE - 1)) - /* * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent * is set by CPUID(HvCpuIdFunctionVersionAndFeatures). @@ -39,78 +28,41 @@ #define HYPERV_CPUID_MAX 0x4000ffff /* - * Feature identification. EAX indicates which features are available - * to the partition based upon the current partition privileges. - * These are HYPERV_CPUID_FEATURES.EAX bits. + * Aliases for Group A features that have X64 in the name. + * On x86/x64 these are HYPERV_CPUID_FEATURES.EAX bits. */ -/* VP Runtime (HV_X64_MSR_VP_RUNTIME) available */ -#define HV_X64_MSR_VP_RUNTIME_AVAILABLE BIT(0) -/* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/ -#define HV_MSR_TIME_REF_COUNT_AVAILABLE BIT(1) -/* - * Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM - * and HV_X64_MSR_SINT0 through HV_X64_MSR_SINT15) available - */ -#define HV_X64_MSR_SYNIC_AVAILABLE BIT(2) -/* - * Synthetic Timer MSRs (HV_X64_MSR_STIMER0_CONFIG through - * HV_X64_MSR_STIMER3_COUNT) available - */ -#define HV_MSR_SYNTIMER_AVAILABLE BIT(3) -/* - * APIC access MSRs (HV_X64_MSR_EOI, HV_X64_MSR_ICR and HV_X64_MSR_TPR) - * are available - */ -#define HV_X64_MSR_APIC_ACCESS_AVAILABLE BIT(4) -/* Hypercall MSRs (HV_X64_MSR_GUEST_OS_ID and HV_X64_MSR_HYPERCALL) available*/ -#define HV_X64_MSR_HYPERCALL_AVAILABLE BIT(5) -/* Access virtual processor index MSR (HV_X64_MSR_VP_INDEX) available*/ -#define HV_X64_MSR_VP_INDEX_AVAILABLE BIT(6) -/* Virtual system reset MSR (HV_X64_MSR_RESET) is available*/ -#define HV_X64_MSR_RESET_AVAILABLE BIT(7) -/* - * Access statistics pages MSRs (HV_X64_MSR_STATS_PARTITION_RETAIL_PAGE, - * HV_X64_MSR_STATS_PARTITION_INTERNAL_PAGE, HV_X64_MSR_STATS_VP_RETAIL_PAGE, - * HV_X64_MSR_STATS_VP_INTERNAL_PAGE) available - */ -#define HV_X64_MSR_STAT_PAGES_AVAILABLE BIT(8) -/* Partition reference TSC MSR is available */ -#define HV_MSR_REFERENCE_TSC_AVAILABLE BIT(9) -/* Partition Guest IDLE MSR is available */ -#define HV_X64_MSR_GUEST_IDLE_AVAILABLE BIT(10) -/* - * There is a single feature flag that signifies if the partition has access - * to MSRs with local APIC and TSC frequencies. - */ -#define HV_X64_ACCESS_FREQUENCY_MSRS BIT(11) -/* AccessReenlightenmentControls privilege */ -#define HV_X64_ACCESS_REENLIGHTENMENT BIT(13) -/* AccessTscInvariantControls privilege */ -#define HV_X64_ACCESS_TSC_INVARIANT BIT(15) +#define HV_X64_MSR_VP_RUNTIME_AVAILABLE \ + HV_MSR_VP_RUNTIME_AVAILABLE +#define HV_X64_MSR_SYNIC_AVAILABLE \ + HV_MSR_SYNIC_AVAILABLE +#define HV_X64_MSR_APIC_ACCESS_AVAILABLE \ + HV_MSR_APIC_ACCESS_AVAILABLE +#define HV_X64_MSR_HYPERCALL_AVAILABLE \ + HV_MSR_HYPERCALL_AVAILABLE +#define HV_X64_MSR_VP_INDEX_AVAILABLE \ + HV_MSR_VP_INDEX_AVAILABLE +#define HV_X64_MSR_RESET_AVAILABLE \ + HV_MSR_RESET_AVAILABLE +#define HV_X64_MSR_GUEST_IDLE_AVAILABLE \ + HV_MSR_GUEST_IDLE_AVAILABLE +#define HV_X64_ACCESS_FREQUENCY_MSRS \ + HV_ACCESS_FREQUENCY_MSRS +#define HV_X64_ACCESS_REENLIGHTENMENT \ + HV_ACCESS_REENLIGHTENMENT +#define HV_X64_ACCESS_TSC_INVARIANT \ + HV_ACCESS_TSC_INVARIANT /* - * Feature identification: indicates which flags were specified at partition - * creation. The format is the same as the partition creation flag structure - * defined in section Partition Creation Flags. - * These are HYPERV_CPUID_FEATURES.EBX bits. + * Aliases for Group B features that have X64 in the name. + * On x86/x64 these are HYPERV_CPUID_FEATURES.EBX bits. */ -#define HV_X64_CREATE_PARTITIONS BIT(0) -#define HV_X64_ACCESS_PARTITION_ID BIT(1) -#define HV_X64_ACCESS_MEMORY_POOL BIT(2) -#define HV_X64_ADJUST_MESSAGE_BUFFERS BIT(3) -#define HV_X64_POST_MESSAGES BIT(4) -#define HV_X64_SIGNAL_EVENTS BIT(5) -#define HV_X64_CREATE_PORT BIT(6) -#define HV_X64_CONNECT_PORT BIT(7) -#define HV_X64_ACCESS_STATS BIT(8) -#define HV_X64_DEBUGGING BIT(11) -#define HV_X64_CPU_POWER_MANAGEMENT BIT(12) +#define HV_X64_POST_MESSAGES HV_POST_MESSAGES +#define HV_X64_SIGNAL_EVENTS HV_SIGNAL_EVENTS /* - * Feature identification. EDX indicates which miscellaneous features - * are available to the partition. - * These are HYPERV_CPUID_FEATURES.EDX bits. + * Group D Features. The bit assignments are custom to each architecture. + * On x86/x64 these are HYPERV_CPUID_FEATURES.EDX bits. */ /* The MWAIT instruction is available (per section MONITOR / MWAIT) */ #define HV_X64_MWAIT_AVAILABLE BIT(0) @@ -187,7 +139,7 @@ * processor, except for virtual processors that are reported as sibling SMT * threads. */ -#define HV_X64_NO_NONARCH_CORESHARING BIT(18) +#define HV_X64_NO_NONARCH_CORESHARING BIT(18) /* Nested features. These are HYPERV_CPUID_NESTED_FEATURES.EAX bits. */ #define HV_X64_NESTED_DIRECT_FLUSH BIT(17) @@ -295,42 +247,6 @@ union hv_x64_msr_hypercall_contents { } __packed; }; -/* - * TSC page layout. - */ -struct ms_hyperv_tsc_page { - volatile u32 tsc_sequence; - u32 reserved1; - volatile u64 tsc_scale; - volatile s64 tsc_offset; -} __packed; - -/* - * The guest OS needs to register the guest ID with the hypervisor. - * The guest ID is a 64 bit entity and the structure of this ID is - * specified in the Hyper-V specification: - * - * msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx - * - * While the current guideline does not specify how Linux guest ID(s) - * need to be generated, our plan is to publish the guidelines for - * Linux and other guest operating systems that currently are hosted - * on Hyper-V. The implementation here conforms to this yet - * unpublished guidelines. - * - * - * Bit(s) - * 63 - Indicates if the OS is Open Source or not; 1 is Open Source - * 62:56 - Os Type; Linux is 0x100 - * 55:48 - Distro specific identification - * 47:16 - Linux kernel version number - * 15:0 - Distro specific identification - * - * - */ - -#define HV_LINUX_VENDOR_ID 0x8100 - struct hv_reenlightenment_control { __u64 vector:8; __u64 reserved1:8; @@ -354,31 +270,12 @@ struct hv_tsc_emulation_status { #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_MASK \ (~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1)) -/* - * Crash notification (HV_X64_MSR_CRASH_CTL) flags. - */ -#define HV_CRASH_CTL_CRASH_NOTIFY_MSG BIT_ULL(62) -#define HV_CRASH_CTL_CRASH_NOTIFY BIT_ULL(63) #define HV_X64_MSR_CRASH_PARAMS \ (1 + (HV_X64_MSR_CRASH_P4 - HV_X64_MSR_CRASH_P0)) #define HV_IPI_LOW_VECTOR 0x10 #define HV_IPI_HIGH_VECTOR 0xff -/* Declare the various hypercall operations. */ -#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE 0x0002 -#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST 0x0003 -#define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008 -#define HVCALL_SEND_IPI 0x000b -#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX 0x0013 -#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX 0x0014 -#define HVCALL_SEND_IPI_EX 0x0015 -#define HVCALL_POST_MESSAGE 0x005c -#define HVCALL_SIGNAL_EVENT 0x005d -#define HVCALL_RETARGET_INTERRUPT 0x007e -#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af -#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST 0x00b0 - #define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE 0x00000001 #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT 12 #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_MASK \ @@ -390,63 +287,6 @@ struct hv_tsc_emulation_status { #define HV_X64_MSR_TSC_REFERENCE_ENABLE 0x00000001 #define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT 12 -#define HV_FLUSH_ALL_PROCESSORS BIT(0) -#define HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES BIT(1) -#define HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY BIT(2) -#define HV_FLUSH_USE_EXTENDED_RANGE_FORMAT BIT(3) - -enum HV_GENERIC_SET_FORMAT { - HV_GENERIC_SET_SPARSE_4K, - HV_GENERIC_SET_ALL, -}; - -#define HV_PARTITION_ID_SELF ((u64)-1) - -#define HV_HYPERCALL_RESULT_MASK GENMASK_ULL(15, 0) -#define HV_HYPERCALL_FAST_BIT BIT(16) -#define HV_HYPERCALL_VARHEAD_OFFSET 17 -#define HV_HYPERCALL_REP_COMP_OFFSET 32 -#define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32) -#define HV_HYPERCALL_REP_START_OFFSET 48 -#define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48) - -/* hypercall status code */ -#define HV_STATUS_SUCCESS 0 -#define HV_STATUS_INVALID_HYPERCALL_CODE 2 -#define HV_STATUS_INVALID_HYPERCALL_INPUT 3 -#define HV_STATUS_INVALID_ALIGNMENT 4 -#define HV_STATUS_INVALID_PARAMETER 5 -#define HV_STATUS_INSUFFICIENT_MEMORY 11 -#define HV_STATUS_INVALID_PORT_ID 17 -#define HV_STATUS_INVALID_CONNECTION_ID 18 -#define HV_STATUS_INSUFFICIENT_BUFFERS 19 - -/* - * The Hyper-V TimeRefCount register and the TSC - * page provide a guest VM clock with 100ns tick rate - */ -#define HV_CLOCK_HZ (NSEC_PER_SEC/100) - -/* Define the number of synthetic interrupt sources. */ -#define HV_SYNIC_SINT_COUNT (16) -/* Define the expected SynIC version. */ -#define HV_SYNIC_VERSION_1 (0x1) -/* Valid SynIC vectors are 16-255. */ -#define HV_SYNIC_FIRST_VALID_VECTOR (16) - -#define HV_SYNIC_CONTROL_ENABLE (1ULL << 0) -#define HV_SYNIC_SIMP_ENABLE (1ULL << 0) -#define HV_SYNIC_SIEFP_ENABLE (1ULL << 0) -#define HV_SYNIC_SINT_MASKED (1ULL << 16) -#define HV_SYNIC_SINT_AUTO_EOI (1ULL << 17) -#define HV_SYNIC_SINT_VECTOR_MASK (0xFF) - -#define HV_SYNIC_STIMER_COUNT (4) - -/* Define synthetic interrupt controller message constants. */ -#define HV_MESSAGE_SIZE (256) -#define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240) -#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30) /* Define hypervisor message types. */ enum hv_message_type { @@ -457,76 +297,25 @@ enum hv_message_type { HVMSG_GPA_INTERCEPT = 0x80000001, /* Timer notification messages. */ - HVMSG_TIMER_EXPIRED = 0x80000010, + HVMSG_TIMER_EXPIRED = 0x80000010, /* Error messages. */ HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020, HVMSG_UNRECOVERABLE_EXCEPTION = 0x80000021, - HVMSG_UNSUPPORTED_FEATURE = 0x80000022, + HVMSG_UNSUPPORTED_FEATURE = 0x80000022, /* Trace buffer complete messages. */ HVMSG_EVENTLOG_BUFFERCOMPLETE = 0x80000040, /* Platform-specific processor intercept messages. */ - HVMSG_X64_IOPORT_INTERCEPT = 0x80010000, + HVMSG_X64_IOPORT_INTERCEPT = 0x80010000, HVMSG_X64_MSR_INTERCEPT = 0x80010001, - HVMSG_X64_CPUID_INTERCEPT = 0x80010002, + HVMSG_X64_CPUID_INTERCEPT = 0x80010002, HVMSG_X64_EXCEPTION_INTERCEPT = 0x80010003, - HVMSG_X64_APIC_EOI = 0x80010004, - HVMSG_X64_LEGACY_FP_ERROR = 0x80010005 + HVMSG_X64_APIC_EOI = 0x80010004, + HVMSG_X64_LEGACY_FP_ERROR = 0x80010005 }; -/* Define synthetic interrupt controller message flags. */ -union hv_message_flags { - __u8 asu8; - struct { - __u8 msg_pending:1; - __u8 reserved:7; - } __packed; -}; - -/* Define port identifier type. */ -union hv_port_id { - __u32 asu32; - struct { - __u32 id:24; - __u32 reserved:8; - } __packed u; -}; - -/* Define synthetic interrupt controller message header. */ -struct hv_message_header { - __u32 message_type; - __u8 payload_size; - union hv_message_flags message_flags; - __u8 reserved[2]; - union { - __u64 sender; - union hv_port_id port; - }; -} __packed; - -/* Define synthetic interrupt controller message format. */ -struct hv_message { - struct hv_message_header header; - union { - __u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT]; - } u; -} __packed; - -/* Define the synthetic interrupt message page layout. */ -struct hv_message_page { - struct hv_message sint_message[HV_SYNIC_SINT_COUNT]; -} __packed; - -/* Define timer message payload structure. */ -struct hv_timer_message_payload { - __u32 timer_index; - __u32 reserved; - __u64 expiration_time; /* When the timer expired */ - __u64 delivery_time; /* When the message was delivered */ -} __packed; - struct hv_nested_enlightenments_control { struct { __u32 directhypercall:1; @@ -754,187 +543,11 @@ struct hv_enlightened_vmcs { #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL 0xFFFF -/* Define synthetic interrupt controller flag constants. */ -#define HV_EVENT_FLAGS_COUNT (256 * 8) -#define HV_EVENT_FLAGS_LONG_COUNT (256 / sizeof(unsigned long)) - -/* - * Synthetic timer configuration. - */ -union hv_stimer_config { - u64 as_uint64; - struct { - u64 enable:1; - u64 periodic:1; - u64 lazy:1; - u64 auto_enable:1; - u64 apic_vector:8; - u64 direct_mode:1; - u64 reserved_z0:3; - u64 sintx:4; - u64 reserved_z1:44; - } __packed; -}; - - -/* Define the synthetic interrupt controller event flags format. */ -union hv_synic_event_flags { - unsigned long flags[HV_EVENT_FLAGS_LONG_COUNT]; -}; - -/* Define SynIC control register. */ -union hv_synic_scontrol { - u64 as_uint64; - struct { - u64 enable:1; - u64 reserved:63; - } __packed; -}; - -/* Define synthetic interrupt source. */ -union hv_synic_sint { - u64 as_uint64; - struct { - u64 vector:8; - u64 reserved1:8; - u64 masked:1; - u64 auto_eoi:1; - u64 polling:1; - u64 reserved2:45; - } __packed; -}; - -/* Define the format of the SIMP register */ -union hv_synic_simp { - u64 as_uint64; - struct { - u64 simp_enabled:1; - u64 preserved:11; - u64 base_simp_gpa:52; - } __packed; -}; - -/* Define the format of the SIEFP register */ -union hv_synic_siefp { - u64 as_uint64; - struct { - u64 siefp_enabled:1; - u64 preserved:11; - u64 base_siefp_gpa:52; - } __packed; -}; - -struct hv_vpset { - u64 format; - u64 valid_bank_mask; - u64 bank_contents[]; -} __packed; - -/* HvCallSendSyntheticClusterIpi hypercall */ -struct hv_send_ipi { - u32 vector; - u32 reserved; - u64 cpu_mask; -} __packed; - -/* HvCallSendSyntheticClusterIpiEx hypercall */ -struct hv_send_ipi_ex { - u32 vector; - u32 reserved; - struct hv_vpset vp_set; -} __packed; - -/* HvFlushGuestPhysicalAddressSpace hypercalls */ -struct hv_guest_mapping_flush { - u64 address_space; - u64 flags; -} __packed; - -/* - * HV_MAX_FLUSH_PAGES = "additional_pages" + 1. It's limited - * by the bitwidth of "additional_pages" in union hv_gpa_page_range. - */ -#define HV_MAX_FLUSH_PAGES (2048) - -/* HvFlushGuestPhysicalAddressList hypercall */ -union hv_gpa_page_range { - u64 address_space; - struct { - u64 additional_pages:11; - u64 largepage:1; - u64 basepfn:52; - } page; -}; - -/* - * All input flush parameters should be in single page. The max flush - * count is equal with how many entries of union hv_gpa_page_range can - * be populated into the input parameter page. - */ -#define HV_MAX_FLUSH_REP_COUNT ((HV_HYP_PAGE_SIZE - 2 * sizeof(u64)) / \ - sizeof(union hv_gpa_page_range)) - -struct hv_guest_mapping_flush_list { - u64 address_space; - u64 flags; - union hv_gpa_page_range gpa_list[HV_MAX_FLUSH_REP_COUNT]; -}; - -/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */ -struct hv_tlb_flush { - u64 address_space; - u64 flags; - u64 processor_mask; - u64 gva_list[]; -} __packed; - -/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */ -struct hv_tlb_flush_ex { - u64 address_space; - u64 flags; - struct hv_vpset hv_vp_set; - u64 gva_list[]; -} __packed; - struct hv_partition_assist_pg { u32 tlb_lock_count; }; -union hv_msi_entry { - u64 as_uint64; - struct { - u32 address; - u32 data; - } __packed; -}; - -struct hv_interrupt_entry { - u32 source; /* 1 for MSI(-X) */ - u32 reserved1; - union hv_msi_entry msi_entry; -} __packed; -/* - * flags for hv_device_interrupt_target.flags - */ -#define HV_DEVICE_INTERRUPT_TARGET_MULTICAST 1 -#define HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET 2 - -struct hv_device_interrupt_target { - u32 vector; - u32 flags; - union { - u64 vp_mask; - struct hv_vpset vp_set; - }; -} __packed; +#include -/* HvRetargetDeviceInterrupt hypercall */ -struct hv_retarget_device_interrupt { - u64 partition_id; /* use "self" */ - u64 device_id; - struct hv_interrupt_entry int_entry; - u64 reserved2; - struct hv_device_interrupt_target int_target; -} __packed __aligned(8); #endif diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h new file mode 100644 index 000000000000..1f92ef92eb56 --- /dev/null +++ b/include/asm-generic/hyperv-tlfs.h @@ -0,0 +1,442 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * This file contains definitions from Hyper-V Hypervisor Top-Level Functional + * Specification (TLFS): + * https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs + */ + +#ifndef _ASM_GENERIC_HYPERV_TLFS_H +#define _ASM_GENERIC_HYPERV_TLFS_H + +#include +#include +#include + +/* + * While not explicitly listed in the TLFS, Hyper-V always runs with a page size + * of 4096. These definitions are used when communicating with Hyper-V using + * guest physical pages and guest physical page addresses, since the guest page + * size may not be 4096 on all architectures. + */ +#define HV_HYP_PAGE_SHIFT 12 +#define HV_HYP_PAGE_SIZE BIT(HV_HYP_PAGE_SHIFT) +#define HV_HYP_PAGE_MASK (~(HV_HYP_PAGE_SIZE - 1)) + +/* + * Hyper-V provides two categories of flags relevant to guest VMs. The + * "Features" category indicates specific functionality that is available + * to guests on this particular instance of Hyper-V. The "Features" + * are presented in four groups, each of which is 32 bits. The group A + * and B definitions are common across architectures and are listed here. + * However, not all flags are relevant on all architectures. + * + * Groups C and D vary across architectures and are listed in the + * architecture specific portion of hyperv-tlfs.h. Some of these flags exist + * on multiple architectures, but the bit positions are different so they + * cannot appear in the generic portion of hyperv-tlfs.h. + * + * The "Enlightenments" category provides recommendations on whether to use + * specific enlightenments that are available. The Enlighenments are a single + * group of 32 bits, but they vary across architectures and are listed in + * the architecture specific portion of hyperv-tlfs.h. + */ + +/* + * Group A Features. + */ + +/* VP Runtime register available */ +#define HV_MSR_VP_RUNTIME_AVAILABLE BIT(0) +/* Partition Reference Counter available*/ +#define HV_MSR_TIME_REF_COUNT_AVAILABLE BIT(1) +/* Basic SynIC register available */ +#define HV_MSR_SYNIC_AVAILABLE BIT(2) +/* Synthetic Timer registers available */ +#define HV_MSR_SYNTIMER_AVAILABLE BIT(3) +/* Virtual APIC assist and VP assist page registers available */ +#define HV_MSR_APIC_ACCESS_AVAILABLE BIT(4) +/* Hypercall and Guest OS ID registers available*/ +#define HV_MSR_HYPERCALL_AVAILABLE BIT(5) +/* Access virtual processor index register available*/ +#define HV_MSR_VP_INDEX_AVAILABLE BIT(6) +/* Virtual system reset register available*/ +#define HV_MSR_RESET_AVAILABLE BIT(7) +/* Access statistics page registers available */ +#define HV_MSR_STAT_PAGES_AVAILABLE BIT(8) +/* Partition reference TSC register is available */ +#define HV_MSR_REFERENCE_TSC_AVAILABLE BIT(9) +/* Partition Guest IDLE register is available */ +#define HV_MSR_GUEST_IDLE_AVAILABLE BIT(10) +/* Partition local APIC and TSC frequency registers available */ +#define HV_ACCESS_FREQUENCY_MSRS BIT(11) +/* AccessReenlightenmentControls privilege */ +#define HV_ACCESS_REENLIGHTENMENT BIT(13) +/* AccessTscInvariantControls privilege */ +#define HV_ACCESS_TSC_INVARIANT BIT(15) + +/* + * Group B features. + */ +#define HV_CREATE_PARTITIONS BIT(0) +#define HV_ACCESS_PARTITION_ID BIT(1) +#define HV_ACCESS_MEMORY_POOL BIT(2) +#define HV_ADJUST_MESSAGE_BUFFERS BIT(3) +#define HV_POST_MESSAGES BIT(4) +#define HV_SIGNAL_EVENTS BIT(5) +#define HV_CREATE_PORT BIT(6) +#define HV_CONNECT_PORT BIT(7) +#define HV_ACCESS_STATS BIT(8) +#define HV_DEBUGGING BIT(11) +#define HV_CPU_POWER_MANAGEMENT BIT(12) + + +/* + * TSC page layout. + */ +struct ms_hyperv_tsc_page { + volatile u32 tsc_sequence; + u32 reserved1; + volatile u64 tsc_scale; + volatile s64 tsc_offset; +} __packed; + +/* + * The guest OS needs to register the guest ID with the hypervisor. + * The guest ID is a 64 bit entity and the structure of this ID is + * specified in the Hyper-V specification: + * + * msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx + * + * While the current guideline does not specify how Linux guest ID(s) + * need to be generated, our plan is to publish the guidelines for + * Linux and other guest operating systems that currently are hosted + * on Hyper-V. The implementation here conforms to this yet + * unpublished guidelines. + * + * + * Bit(s) + * 63 - Indicates if the OS is Open Source or not; 1 is Open Source + * 62:56 - Os Type; Linux is 0x100 + * 55:48 - Distro specific identification + * 47:16 - Linux kernel version number + * 15:0 - Distro specific identification + * + * + */ + +#define HV_LINUX_VENDOR_ID 0x8100 + +/* + * Crash notification flags. + */ +#define HV_CRASH_CTL_CRASH_NOTIFY_MSG BIT_ULL(62) +#define HV_CRASH_CTL_CRASH_NOTIFY BIT_ULL(63) + +/* Declare the various hypercall operations. */ +#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE 0x0002 +#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST 0x0003 +#define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008 +#define HVCALL_SEND_IPI 0x000b +#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX 0x0013 +#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX 0x0014 +#define HVCALL_SEND_IPI_EX 0x0015 +#define HVCALL_POST_MESSAGE 0x005c +#define HVCALL_SIGNAL_EVENT 0x005d +#define HVCALL_RETARGET_INTERRUPT 0x007e +#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af +#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST 0x00b0 + +#define HV_FLUSH_ALL_PROCESSORS BIT(0) +#define HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES BIT(1) +#define HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY BIT(2) +#define HV_FLUSH_USE_EXTENDED_RANGE_FORMAT BIT(3) + +enum HV_GENERIC_SET_FORMAT { + HV_GENERIC_SET_SPARSE_4K, + HV_GENERIC_SET_ALL, +}; + +#define HV_PARTITION_ID_SELF ((u64)-1) +#define HV_VP_INDEX_SELF ((u32)-2) + +#define HV_HYPERCALL_RESULT_MASK GENMASK_ULL(15, 0) +#define HV_HYPERCALL_FAST_BIT BIT(16) +#define HV_HYPERCALL_VARHEAD_OFFSET 17 +#define HV_HYPERCALL_REP_COMP_OFFSET 32 +#define HV_HYPERCALL_REP_COMP_1 BIT_ULL(32) +#define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32) +#define HV_HYPERCALL_REP_START_OFFSET 48 +#define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48) + +/* hypercall status code */ +#define HV_STATUS_SUCCESS 0 +#define HV_STATUS_INVALID_HYPERCALL_CODE 2 +#define HV_STATUS_INVALID_HYPERCALL_INPUT 3 +#define HV_STATUS_INVALID_ALIGNMENT 4 +#define HV_STATUS_INVALID_PARAMETER 5 +#define HV_STATUS_INSUFFICIENT_MEMORY 11 +#define HV_STATUS_INVALID_PORT_ID 17 +#define HV_STATUS_INVALID_CONNECTION_ID 18 +#define HV_STATUS_INSUFFICIENT_BUFFERS 19 + +/* + * The Hyper-V TimeRefCount register and the TSC + * page provide a guest VM clock with 100ns tick rate + */ +#define HV_CLOCK_HZ (NSEC_PER_SEC/100) + +/* Define the number of synthetic interrupt sources. */ +#define HV_SYNIC_SINT_COUNT (16) +/* Define the expected SynIC version. */ +#define HV_SYNIC_VERSION_1 (0x1) +/* Valid SynIC vectors are 16-255. */ +#define HV_SYNIC_FIRST_VALID_VECTOR (16) + +#define HV_SYNIC_CONTROL_ENABLE (1ULL << 0) +#define HV_SYNIC_SIMP_ENABLE (1ULL << 0) +#define HV_SYNIC_SIEFP_ENABLE (1ULL << 0) +#define HV_SYNIC_SINT_MASKED (1ULL << 16) +#define HV_SYNIC_SINT_AUTO_EOI (1ULL << 17) +#define HV_SYNIC_SINT_VECTOR_MASK (0xFF) + +#define HV_SYNIC_STIMER_COUNT (4) + +/* Define synthetic interrupt controller message constants. */ +#define HV_MESSAGE_SIZE (256) +#define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240) +#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30) + +/* Define synthetic interrupt controller message flags. */ +union hv_message_flags { + __u8 asu8; + struct { + __u8 msg_pending:1; + __u8 reserved:7; + } __packed; +}; + +/* Define port identifier type. */ +union hv_port_id { + __u32 asu32; + struct { + __u32 id:24; + __u32 reserved:8; + } __packed u; +}; + +/* Define synthetic interrupt controller message header. */ +struct hv_message_header { + __u32 message_type; + __u8 payload_size; + union hv_message_flags message_flags; + __u8 reserved[2]; + union { + __u64 sender; + union hv_port_id port; + }; +} __packed; + +/* Define synthetic interrupt controller message format. */ +struct hv_message { + struct hv_message_header header; + union { + __u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT]; + } u; +} __packed; + +/* Define the synthetic interrupt message page layout. */ +struct hv_message_page { + struct hv_message sint_message[HV_SYNIC_SINT_COUNT]; +} __packed; + +/* Define timer message payload structure. */ +struct hv_timer_message_payload { + __u32 timer_index; + __u32 reserved; + __u64 expiration_time; /* When the timer expired */ + __u64 delivery_time; /* When the message was delivered */ +} __packed; + + +/* Define synthetic interrupt controller flag constants. */ +#define HV_EVENT_FLAGS_COUNT (256 * 8) +#define HV_EVENT_FLAGS_LONG_COUNT (256 / sizeof(unsigned long)) + +/* + * Synthetic timer configuration. + */ +union hv_stimer_config { + u64 as_uint64; + struct { + u64 enable:1; + u64 periodic:1; + u64 lazy:1; + u64 auto_enable:1; + u64 apic_vector:8; + u64 direct_mode:1; + u64 reserved_z0:3; + u64 sintx:4; + u64 reserved_z1:44; + } __packed; +}; + + +/* Define the synthetic interrupt controller event flags format. */ +union hv_synic_event_flags { + unsigned long flags[HV_EVENT_FLAGS_LONG_COUNT]; +}; + +/* Define SynIC control register. */ +union hv_synic_scontrol { + u64 as_uint64; + struct { + u64 enable:1; + u64 reserved:63; + } __packed; +}; + +/* Define synthetic interrupt source. */ +union hv_synic_sint { + u64 as_uint64; + struct { + u64 vector:8; + u64 reserved1:8; + u64 masked:1; + u64 auto_eoi:1; + u64 polling:1; + u64 reserved2:45; + } __packed; +}; + +/* Define the format of the SIMP register */ +union hv_synic_simp { + u64 as_uint64; + struct { + u64 simp_enabled:1; + u64 preserved:11; + u64 base_simp_gpa:52; + } __packed; +}; + +/* Define the format of the SIEFP register */ +union hv_synic_siefp { + u64 as_uint64; + struct { + u64 siefp_enabled:1; + u64 preserved:11; + u64 base_siefp_gpa:52; + } __packed; +}; + +struct hv_vpset { + u64 format; + u64 valid_bank_mask; + u64 bank_contents[]; +} __packed; + +/* HvCallSendSyntheticClusterIpi hypercall */ +struct hv_send_ipi { + u32 vector; + u32 reserved; + u64 cpu_mask; +} __packed; + +/* HvCallSendSyntheticClusterIpiEx hypercall */ +struct hv_send_ipi_ex { + u32 vector; + u32 reserved; + struct hv_vpset vp_set; +} __packed; + +/* HvFlushGuestPhysicalAddressSpace hypercalls */ +struct hv_guest_mapping_flush { + u64 address_space; + u64 flags; +} __packed; + +/* + * HV_MAX_FLUSH_PAGES = "additional_pages" + 1. It's limited + * by the bitwidth of "additional_pages" in union hv_gpa_page_range. + */ +#define HV_MAX_FLUSH_PAGES (2048) + +/* HvFlushGuestPhysicalAddressList hypercall */ +union hv_gpa_page_range { + u64 address_space; + struct { + u64 additional_pages:11; + u64 largepage:1; + u64 basepfn:52; + } page; +}; + +/* + * All input flush parameters should be in single page. The max flush + * count is equal with how many entries of union hv_gpa_page_range can + * be populated into the input parameter page. + */ +#define HV_MAX_FLUSH_REP_COUNT ((HV_HYP_PAGE_SIZE - 2 * sizeof(u64)) / \ + sizeof(union hv_gpa_page_range)) + +struct hv_guest_mapping_flush_list { + u64 address_space; + u64 flags; + union hv_gpa_page_range gpa_list[HV_MAX_FLUSH_REP_COUNT]; +}; + +/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */ +struct hv_tlb_flush { + u64 address_space; + u64 flags; + u64 processor_mask; + u64 gva_list[]; +} __packed; + +/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */ +struct hv_tlb_flush_ex { + u64 address_space; + u64 flags; + struct hv_vpset hv_vp_set; + u64 gva_list[]; +} __packed; + +/* HvRetargetDeviceInterrupt hypercall */ +union hv_msi_entry { + u64 as_uint64; + struct { + u32 address; + u32 data; + } __packed; +}; + +struct hv_interrupt_entry { + u32 source; /* 1 for MSI(-X) */ + u32 reserved1; + union hv_msi_entry msi_entry; +} __packed; + +/* + * flags for hv_device_interrupt_target.flags + */ +#define HV_DEVICE_INTERRUPT_TARGET_MULTICAST 1 +#define HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET 2 + +struct hv_device_interrupt_target { + u32 vector; + u32 flags; + union { + u64 vp_mask; + struct hv_vpset vp_set; + }; +} __packed; + +struct hv_retarget_device_interrupt { + u64 partition_id; /* use "self" */ + u64 device_id; + struct hv_interrupt_entry int_entry; + u64 reserved2; + struct hv_device_interrupt_target int_target; +} __packed __aligned(8); + +#endif From patchwork Wed Apr 22 19:57:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael Kelley (LINUX)" X-Patchwork-Id: 11504455 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3752B14DD for ; Wed, 22 Apr 2020 19:58:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1ACC221556 for ; Wed, 22 Apr 2020 19:58:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b="Ga+QguCx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726694AbgDVT6z (ORCPT ); Wed, 22 Apr 2020 15:58:55 -0400 Received: from mail-dm6nam11on2123.outbound.protection.outlook.com ([40.107.223.123]:64928 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726614AbgDVT6y (ORCPT ); Wed, 22 Apr 2020 15:58:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fWTHfqFaBIfpBLaleRJYwXNWaANyWqX4CF/yeqX+q0BnqxCqQFrTW6M8gaFmhk3dDYg4SYd+XZW7OdTAZ7FrK5ZyNibfj2WtC+aFV6ImtukplUfPiL8UbFuH41GwDb85BqlQn+eW2S+piHzcjDiHlvK84CJyXSCVZfOz2wPrg3gKEiq0Ej/x2kxnlcT5bjhq4r45K5GmMp+Z7/RPFwqurgza51goJJI6JSNB8wMiIaIpBQFINo0LoOABHBmpg21avR6E8gP9+rHNceuR/XZnXJZlg5KgAGuCJGhF6vu48+TQXBd0kBbpOkUTAFJK1xNtXUz11gO6roBlMjG2l8CY9g== 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=eUlJw9P/OOM2qz0EBHFoCmBbRJGN+J/GvcOvVZOShqs=; b=YDgO7lz1vErBxnLtEV63KvDns0pNJ591iCQgxXQ6r/WYt5QBXlFk3ZV0jQGX8hmwdOsdaXIbIWNYq9vtv9AXK7tKyITXGcos/aUsM8S2dhGLQQsbEtMePQqkoKpFcmM3HT11x1xnzgKfbyD40/jWkeAiOF4M6u8nGFVJA6BBrvR2nqW5CjikvHE+GG3WHijh6wUSeMTiPSHIMResi0YoTCS8/J4wYWpm1idDL8KJpbZDGK6jn1FSIqLh4El9bwYbXfj641VY4kieCsZKTgo6FqQqJNRBKrHlkCbYrpFZPi2CykdAZlLppyFQSF4zMQ8zWjoEEt3wrorK/M56pDonxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eUlJw9P/OOM2qz0EBHFoCmBbRJGN+J/GvcOvVZOShqs=; b=Ga+QguCx9qVPK2sc1jzgAVCX/CmCcwHQtjZc7HSkDkW1PI+7o4y7POAWwKDroZdEXoEd487SFSDAPwldWE9nJ6Dch+ckreLf+lvymRoPrSXrgUQtHAVkFKMrrFiq5Jc5qco/NqHfsjpAmsYn8astSjfQLyF4CoKSFyzVbfVStd0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=mikelley@microsoft.com; Received: from BN6PR21MB0178.namprd21.prod.outlook.com (2603:10b6:404:94::12) by BN6PR21MB0148.namprd21.prod.outlook.com (2603:10b6:404:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.2; Wed, 22 Apr 2020 19:58:43 +0000 Received: from BN6PR21MB0178.namprd21.prod.outlook.com ([fe80::a97c:360c:9ed2:12ec]) by BN6PR21MB0178.namprd21.prod.outlook.com ([fe80::a97c:360c:9ed2:12ec%11]) with mapi id 15.20.2958.001; Wed, 22 Apr 2020 19:58:43 +0000 From: Michael Kelley To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, pbonzini@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Cc: mikelley@microsoft.com Subject: [PATCH v2 4/4] asm-generic/hyperv: Add definitions for Get/SetVpRegister hypercalls Date: Wed, 22 Apr 2020 12:57:37 -0700 Message-Id: <20200422195737.10223-5-mikelley@microsoft.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200422195737.10223-1-mikelley@microsoft.com> References: <20200422195737.10223-1-mikelley@microsoft.com> X-ClientProxiedBy: MWHPR19CA0078.namprd19.prod.outlook.com (2603:10b6:320:1f::16) To BN6PR21MB0178.namprd21.prod.outlook.com (2603:10b6:404:94::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from MHKdev.corp.microsoft.com (167.220.2.108) by MWHPR19CA0078.namprd19.prod.outlook.com (2603:10b6:320:1f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13 via Frontend Transport; Wed, 22 Apr 2020 19:58:41 +0000 X-Mailer: git-send-email 2.18.2 X-Originating-IP: [167.220.2.108] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8ab8775a-53e2-40ab-8445-08d7e6f78f2f X-MS-TrafficTypeDiagnostic: BN6PR21MB0148:|BN6PR21MB0148:|BN6PR21MB0148: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:359; X-Forefront-PRVS: 03818C953D X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR21MB0178.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(6029001)(4636009)(346002)(136003)(396003)(366004)(376002)(39860400002)(81156014)(82960400001)(8936002)(10290500003)(4326008)(26005)(82950400001)(5660300002)(107886003)(956004)(2616005)(478600001)(66556008)(66946007)(66476007)(6486002)(1076003)(86362001)(6666004)(316002)(8676002)(2906002)(16526019)(186003)(36756003)(52116002)(7696005)(7416002)(41533002)(921003);DIR:OUT;SFP:1102; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6rHlbaHYreG2jG5H3cuq98HvXQ/k2NH6xXYuV9tXkncKTzJdkLknQVtSkVcySeLhg10WUE0mMN0zEKb3wY71iwPUq6g1LiN3hAax7n0QfgGN0Ah0ZzaARu6Mwhi17431Nj62kNg4Cvzq/fuGmrAU5QK4tH7doXzKbalMtVshwit2WwQgBsx4zzMs5W2/2LIMAlnN1D5RvOnm/SYrsEEnGVX80y6l/h4xw7KoxJ14Nu6viyltBjTRMdJmB7YTsRcJ9a5QzXapErJPB5/WXnpF462ZNGRP6g4vUwLLfj5uqIETXfB13jBTd2RsEbB5k9Pc9RqXSCWn1aN/sRkjdOVzAwsbAZ8G9E1hEc7vP5x+9DNFS7mzQq3ouMX5are19bUC5H8eIatFjMZZjqlPP1js65U4Ovg8mHJ/UeHGFyjl3JIelA7JQzQ3UVJ8WmoGC5vHNX0S6Xss6WkctFhO4hFg1OTyRVV1PHI6ouWXmimqJHljQkU1pOtepOIXYTTzWjTC X-MS-Exchange-AntiSpam-MessageData: W7prDTzONe2iL1D9DGRJGOtjLU9Nq2IMIzqw+OcVheMW/IEKf+fg2cHj+7Wi8k/0fH2g0Po5OMm8SajljmCLlgMga7RCb6wERWBH85Qwy+rPKscQn/h4eqvW2Lc962u8fKnaJHLWm1MM7+yGkYpPXsoCedk2cZuPr+2AxrQAODeqQrk0pNCMyl2a8lu0CiGRmugVKQZLm7vVzG7JfZx6Znp0NvxjVAz5FAZOSQDSMqcnQNyxE6HbTqM5f/ZAoNwlKc/E0C8QHl1cncdxNtj+c8HYxoaaEpEST51fZ1o0HS6nq0y9cnfN+hzSGHSrSSiSNLPoH/cEgfjDT/IUlbpSgku0zpQfj1LL/PqBQOmVbAs3ByRjJ9TIOKdfjjB17NpsG7yO49jYLdDn7gEzLx0YmgLMCjz67bvAITbiofwJMXipnK4w+4CIaVNWQCaKDGEpkBqle6zji2xkguZ2ezIqjsMuHizuiWnXN8k8GCCcFyMZDSZ/R4RDkdWMAbxQoplA1SpHNNyrWjzJXF2z81SVZr1oD1BQuQtI0AH7b7n+JeGWixKHmFrzhX17BD96SqDBdjScvb9KNOwieCBjlO0NBDDYUnGchlL5rWNIKesFwu7ltCTRMoHS5fJ2YY4OCemnu6qXSr7U+6iaGQGZwTQdzlIyw4yoMT5NNFB+0QcjW8VF++z3fTmW025moE2Y5JVl2dv80Q7GJ0F45w+zw76L4ZuqT7Gvuyno6Iccl5jl8+aBU8BwhTqpOgONohH3GhB6UXEGr9fupS7U29P/V9z7hmadqfBtnLCKgq+Rj97k5V8= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ab8775a-53e2-40ab-8445-08d7e6f78f2f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2020 19:58:43.1160 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YGDnM3RTtbSSi5JAT1gJPbXaw5yEcEwahUOX0adgSf/stgWkJ39DCVz/UwpA63YtGvW+wW6HfuNTmdlDXw+4pQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR21MB0148 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add definitions for GetVpRegister and SetVpRegister hypercalls, which are implemented for both x86 and ARM64. Signed-off-by: Michael Kelley Reviewed-by: Vitaly Kuznetsov --- include/asm-generic/hyperv-tlfs.h | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h index 1f92ef92eb56..262fae9526b1 100644 --- a/include/asm-generic/hyperv-tlfs.h +++ b/include/asm-generic/hyperv-tlfs.h @@ -141,6 +141,8 @@ struct ms_hyperv_tsc_page { #define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX 0x0013 #define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX 0x0014 #define HVCALL_SEND_IPI_EX 0x0015 +#define HVCALL_GET_VP_REGISTERS 0x0050 +#define HVCALL_SET_VP_REGISTERS 0x0051 #define HVCALL_POST_MESSAGE 0x005c #define HVCALL_SIGNAL_EVENT 0x005d #define HVCALL_RETARGET_INTERRUPT 0x007e @@ -439,4 +441,53 @@ struct hv_retarget_device_interrupt { struct hv_device_interrupt_target int_target; } __packed __aligned(8); + +/* HvGetVpRegisters hypercall input with variable size reg name list*/ +struct hv_get_vp_registers_input { + struct { + u64 partitionid; + u32 vpindex; + u8 inputvtl; + u8 padding[3]; + } header; + struct input { + u32 name0; + u32 name1; + } element[]; +} __packed; + + +/* HvGetVpRegisters returns an array of these output elements */ +struct hv_get_vp_registers_output { + union { + struct { + u32 a; + u32 b; + u32 c; + u32 d; + } as32 __packed; + struct { + u64 low; + u64 high; + } as64 __packed; + }; +}; + +/* HvSetVpRegisters hypercall with variable size reg name/value list*/ +struct hv_set_vp_registers_input { + struct { + u64 partitionid; + u32 vpindex; + u8 inputvtl; + u8 padding[3]; + } header; + struct { + u32 name; + u32 padding1; + u64 padding2; + u64 valuelow; + u64 valuehigh; + } element[]; +} __packed; + #endif