From patchwork Fri Dec 1 23:24:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Makhalov X-Patchwork-Id: 749302 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=vmware.com header.i=@vmware.com header.b="s93TrmUJ" Received: from MW2PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012013.outbound.protection.outlook.com [52.101.48.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F77E85; Fri, 1 Dec 2023 15:25:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CrVAHURCecxAqg+7JqxLP23FN7xYVLDKOKagNyluO5EkCrq/0XNC64U3lDABYfyurRcmF/qON1zOiFllz9MgEy2pW9TWppXICU1wko+0w4yTedtbu4bS8+vxGWcrROH1B+118O+KX25aEPZPgJ8nukTtxAQ/CgmqfJIjd4FQVNphcaXXt5wlxanqrgyn37a2jOEYNZIrNtnNTvaiN+Lr39LN6UPraFUPUgocXwoyo6CA61rHAmZ//3SUzire21dswtkL1SfZ6KE2g2+/UqYdB49wHdgAjNOxE3VJKQvf/Mi1GiZirXWxYP2nXVqFYivC5aGMRlozsCVWVZYY9l0trA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DJ+gRkoGbU3l0zmNQ1Fq7uSrv1o6gbhB8z13Z2qxmkg=; b=gupRcuu7cXw/K9tmWUOpZV/uv6ufIIBJaCStX+kgFDF5DZySwRDMbqRf3Quy7CTU1yC/H0OOSwYd3UP7XK4xYKCyZtVKe6uqdJA0fpridZGLtwQP5nI+KCIogfieBxeoK7kRnhxobNyeeyDJ5H3v5lMERSmz02/OgsK61FiEC8qM3ovNOoY2vBbLxX78CyziaVTWE2rrCFSf55Zrk0OJbgnkJE+VwiFFtnh0aalYTLiys6zYd5z+3r8Td72AwYq1fA/fAvYTsm0Gb77mqMXo63BkhvmmKkjLT5LN6vLEvrQ2gZNVvP2CUSZpLbXSiuwNHEpyhOuwXrGfDIbCqbLALQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DJ+gRkoGbU3l0zmNQ1Fq7uSrv1o6gbhB8z13Z2qxmkg=; b=s93TrmUJuzvg4VLrLkDUG7Brm4gzBeXZxkhHcAWQ11CGFoMKiYn7VFeyrIXkuuag1njzJJZTXxjrLPY0d0ic5SDePnO859iUsIsYNBbQPEQ2PdpmRjGruEIpOvmWRKZc2kBCeDNjSmFj2a1vLUgHIMgwUNQmZXANDREYdECfWBM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vmware.com; Received: from MWHPR05MB3648.namprd05.prod.outlook.com (2603:10b6:301:45::23) by SJ0PR05MB7787.namprd05.prod.outlook.com (2603:10b6:a03:2e4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27; Fri, 1 Dec 2023 23:25:06 +0000 Received: from MWHPR05MB3648.namprd05.prod.outlook.com ([fe80::10f0:590a:708:4ad7]) by MWHPR05MB3648.namprd05.prod.outlook.com ([fe80::10f0:590a:708:4ad7%2]) with mapi id 15.20.7025.021; Fri, 1 Dec 2023 23:25:06 +0000 From: Alexey Makhalov To: linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, hpa@zytor.com, dave.hansen@linux.intel.co, bp@alien8.d, mingo@redhat.com, tglx@linutronix.de Cc: x86@kernel.org, netdev@vger.kernel.org, richardcochran@gmail.com, linux-input@vger.kernel.org, dmitry.torokhov@gmail.com, zackr@vmware.com, linux-graphics-maintainer@vmware.com, pv-drivers@vmware.com, namit@vmware.com, timothym@vmware.com, akaher@vmware.com, jsipek@vmware.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch, airlied@gmail.com, tzimmermann@suse.de, mripard@kernel.org, maarten.lankhorst@linux.intel.com, horms@kernel.org Subject: [PATCH v2 1/6] x86/vmware: Move common macros to vmware.h Date: Fri, 1 Dec 2023 15:24:47 -0800 Message-Id: <20231201232452.220355-2-amakhalov@vmware.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201232452.220355-1-amakhalov@vmware.com> References: <20231122233058.185601-8-amakhalov@vmware.com> <20231201232452.220355-1-amakhalov@vmware.com> X-ClientProxiedBy: SJ2PR07CA0017.namprd07.prod.outlook.com (2603:10b6:a03:505::17) To MWHPR05MB3648.namprd05.prod.outlook.com (2603:10b6:301:45::23) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR05MB3648:EE_|SJ0PR05MB7787:EE_ X-MS-Office365-Filtering-Correlation-Id: a170113b-653f-4522-f9ea-08dbf2c4c09e X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtFwd,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E+ue7dd1rPbX6VHLHTmuxXx3D9L+CVQwNr3VRjn+J7eXXB31915SmtXQWdmHE4pXF20dzrAU843AQ95Q1RA2Y/bYZP/lBUX5NiSTAQQr4nl2ySvCFw6RcWDo7g79j2DmNHoufQW9L4ZLosYlJszTUTefUZZvhzev/cL3/WUDXP1vCDx3eDwDzyixfq/fWR0m5ZvO44BpTpslsyto3n8vpRmqlZCl0mk0JEti6xuxpofs7RG15VKdl8x6T9zvVpZUjH5/XHbmoJCk/+6fJGl3ZamHkzbsIA0cabL5fSVi9sCwiEfRoDl7+VwZna4XszkVCRgG/eFTnripIqUPw0ysdMK//tfUYyrG2de6rNwDv7jNcw5hGngVWe53ovsq1uUKmYVK+FFvBlQDqrrd2gcD4VRGwfAE7F+y0/3YZ/D3KK5Jc1eDQKmW2kEtf0n9/4YYxsrSr4cD8gu2zfhWvFzDninMR19aaj3QAp7u9PdZ9Sz0qN83qjYZtYgcWckkfwoO1iBbmeQaJlod/zaN+9jJWsAyeFpyve49fPNg/gXv2VdSurl1gVoakTEsy26LCPR2ZS5VbQfoHNOTj+Aomnvq+r8yMl1WiS0Nwz08hTYAgHXarW7Mh1GnQn8d56AnWS/pbE+xXpvjRYFrRdmRMMFBZi3X3Tp0JEq0Jixmptw0rlM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR05MB3648.namprd05.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(346002)(366004)(376002)(396003)(136003)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(36756003)(8936002)(316002)(66556008)(66946007)(66476007)(8676002)(4326008)(478600001)(6486002)(41300700001)(2906002)(7416002)(86362001)(5660300002)(38350700005)(38100700002)(2616005)(26005)(1076003)(6666004)(6506007)(52116002)(83380400001)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KB2Qp5y40fjnaSAe/oDoEDyi9u85tGoF4sAu9zMPD9ZahkaXTeDPG8xnzTEH7baMO9Js6tYGp2Ex1o8lx49crJOddPeuoOyP3JtEZ2+2MevcgkAO6F4LI61c+2n02kvK+/TELZ3oZ3nYb5BlDa2JLhK0LhOGxA0eVpzFGuPVuxIN7tBqwBDQUyooS+ESqeY4hHafjrKESkqZrngTjpEQRy1UHFkM3GY+b58vCIdGS8YxjPvdM++GLP5dVHN++uuVHXKsz/IMViRO+5zUUem3C+sWZpeWE98T4G92JEQf7O6WEE67OJ7vn7RkFxD/4nq5xylPpvCfzyJuoA4/jyDq8bVlvGVcNm71sIvOOE6Is/jrsdeK6bYKzjWj7T8yzge2el5eGJxs5VJZ12CJo4MIhj0T+38H/bpEG4s+JyRBGJYvJ66DHpKgGMvJWy6zWm4CcNboZB1Sc4mL0WxX4XByFJOV4dXFkIw7n06QMQppaOLYwMAWLZ+ziED6yTPqibdsT8FxwN0t0DqaqZZghX1VlnzZ+RCDLZIavKq0hrN5vC/lEmfVgKtVtC28hSYSZ4dGzb2ng8vUMPZeLEf7VpDG6/UTMzCNjOAhWhs1m7OwmQBvBCxsGoOwn+aP9deoHoc+1E8DUWdnpBdjobMaNXvd4Ap4yYdFTjd4qJ0pC16xBaZ8M7IUQ9rxA/Fmv1FU0XOOVMqkDEooXKUqOwn6Z8UQQWvspHBKF9IumNO5KsPiSf0RSy6cA0/X6ihos3zGSREvRhhVuJ+YkwUMFveeAwOEr/6KV0nreaAxozetZd3d9jmFOEhsNK0fW+q0cvmGNc4KsrvDlc68h5UsRz4Vx7w1tbj2ka8h0TqGNuN40ET8yZcBZVYhjowGE4KnUmy6BS1BqnQzgzN1TfmnZ07vTCwJCMqWGS0z+Lf8BsehbLHG+A545C/95zr2HQHC4RRGgml16pmAlpHXI+YrmQ9qylhoMePN0653y10kYm3r/1jT2eFa8Zr+ZVlyehRrvnMDLCoA0imhpAoUhb65C5wqfmWeKcli4R+todhUUKRGIxs7+zOGK87tIu3fJlme5235CcVFqPUechuuj32VX3qKJY7jhZp3L6GSy57OevsSUal+JcvWiyHRvAx2f1c6AnNrxnRl4za5UkuGZqXrgmIa/dWbRsqsSQhBO0s3F9Hddw0Y7opTUmH7mrxAMfL3rvM8oVHw98YE+KoXSm7u3H9o75dOETZNdkQWKeiROdSRdpifWaA0qa+Xp4iOp3AXbH0aCHCSyxeFOtDDCymMuZdYA5hnmkVnJxvp9txx6CaZvtzyYxbo09i3nh4o3XTtQQmAipsny8gQCptHFVLQXz4oDW0XYneO8cGtfG693uFeNQfAZL9oDmFn/1KM3TT2m7xHYgaq//EA0Bf+MgYCGjAJ3Dfktv2QytGRlesoZ+yAJd3Q8YDvsTIuMh2l0ylq8pKOlJATtibZhRICe/QWw6IOrSx1/qJeO2Tu2KKya6Lykkmhj3jDMYIFtLGu5KLm6Ba8988duVJ/pEsVClO++35LWjpCoL0+snuo+0EFylE5oMWfA6h2SDOr3dsQrleD/ByXw2aj X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: a170113b-653f-4522-f9ea-08dbf2c4c09e X-MS-Exchange-CrossTenant-AuthSource: MWHPR05MB3648.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 23:25:06.5954 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PE28J+N4xO8yaunaFew+Thwnx4Mkw9unuu6t9r5UeV9ngu1ExT5a++pXG8lHMDyJBBvP66POXvK2WllQ6b8ZeQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR05MB7787 Move VMware hypercall macros to vmware.h as a preparation step for the next commit. No functional changes besides exporting vmware_hypercall_mode symbol. Signed-off-by: Alexey Makhalov Reviewed-by: Nadav Amit --- arch/x86/include/asm/vmware.h | 69 ++++++++++++++++++++++++++++++----- arch/x86/kernel/cpu/vmware.c | 57 +++-------------------------- 2 files changed, 66 insertions(+), 60 deletions(-) diff --git a/arch/x86/include/asm/vmware.h b/arch/x86/include/asm/vmware.h index ac9fc51e2b18..8cabf4a577bf 100644 --- a/arch/x86/include/asm/vmware.h +++ b/arch/x86/include/asm/vmware.h @@ -8,25 +8,37 @@ /* * The hypercall definitions differ in the low word of the %edx argument - * in the following way: the old port base interface uses the port - * number to distinguish between high- and low bandwidth versions. + * in the following way: the old I/O port based interface uses the port + * number to distinguish between high- and low bandwidth versions, and + * uses IN/OUT instructions to define transfer direction. * * The new vmcall interface instead uses a set of flags to select * bandwidth mode and transfer direction. The flags should be loaded * into %dx by any user and are automatically replaced by the port - * number if the VMWARE_HYPERVISOR_PORT method is used. + * number if the I/O port method is used. * * In short, new driver code should strictly use the new definition of * %dx content. */ -/* Old port-based version */ -#define VMWARE_HYPERVISOR_PORT 0x5658 -#define VMWARE_HYPERVISOR_PORT_HB 0x5659 +#define VMWARE_HYPERVISOR_HB BIT(0) +#define VMWARE_HYPERVISOR_OUT BIT(1) -/* Current vmcall / vmmcall version */ -#define VMWARE_HYPERVISOR_HB BIT(0) -#define VMWARE_HYPERVISOR_OUT BIT(1) +#define VMWARE_HYPERVISOR_PORT 0x5658 +#define VMWARE_HYPERVISOR_PORT_HB (VMWARE_HYPERVISOR_PORT | \ + VMWARE_HYPERVISOR_HB) + +#define VMWARE_HYPERVISOR_MAGIC 0x564D5868U + +#define VMWARE_CMD_GETVERSION 10 +#define VMWARE_CMD_GETHZ 45 +#define VMWARE_CMD_GETVCPU_INFO 68 +#define VMWARE_CMD_STEALCLOCK 91 + +#define CPUID_VMWARE_FEATURES_ECX_VMMCALL BIT(0) +#define CPUID_VMWARE_FEATURES_ECX_VMCALL BIT(1) + +extern u8 vmware_hypercall_mode; /* The low bandwidth call. The low word of edx is presumed clear. */ #define VMWARE_HYPERCALL \ @@ -54,4 +66,43 @@ "rep insb", \ "vmcall", X86_FEATURE_VMCALL, \ "vmmcall", X86_FEATURE_VMW_VMMCALL) + +#define VMWARE_PORT(cmd, eax, ebx, ecx, edx) \ + __asm__("inl (%%dx), %%eax" : \ + "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \ + "a"(VMWARE_HYPERVISOR_MAGIC), \ + "c"(VMWARE_CMD_##cmd), \ + "d"(VMWARE_HYPERVISOR_PORT), "b"(UINT_MAX) : \ + "memory") + +#define VMWARE_VMCALL(cmd, eax, ebx, ecx, edx) \ + __asm__("vmcall" : \ + "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \ + "a"(VMWARE_HYPERVISOR_MAGIC), \ + "c"(VMWARE_CMD_##cmd), \ + "d"(0), "b"(UINT_MAX) : \ + "memory") + +#define VMWARE_VMMCALL(cmd, eax, ebx, ecx, edx) \ + __asm__("vmmcall" : \ + "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \ + "a"(VMWARE_HYPERVISOR_MAGIC), \ + "c"(VMWARE_CMD_##cmd), \ + "d"(0), "b"(UINT_MAX) : \ + "memory") + +#define VMWARE_CMD(cmd, eax, ebx, ecx, edx) do { \ + switch (vmware_hypercall_mode) { \ + case CPUID_VMWARE_FEATURES_ECX_VMCALL: \ + VMWARE_VMCALL(cmd, eax, ebx, ecx, edx); \ + break; \ + case CPUID_VMWARE_FEATURES_ECX_VMMCALL: \ + VMWARE_VMMCALL(cmd, eax, ebx, ecx, edx); \ + break; \ + default: \ + VMWARE_PORT(cmd, eax, ebx, ecx, edx); \ + break; \ + } \ + } while (0) + #endif diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c index 11f83d07925e..4db8e1daa4a1 100644 --- a/arch/x86/kernel/cpu/vmware.c +++ b/arch/x86/kernel/cpu/vmware.c @@ -41,60 +41,14 @@ #define CPUID_VMWARE_INFO_LEAF 0x40000000 #define CPUID_VMWARE_FEATURES_LEAF 0x40000010 -#define CPUID_VMWARE_FEATURES_ECX_VMMCALL BIT(0) -#define CPUID_VMWARE_FEATURES_ECX_VMCALL BIT(1) -#define VMWARE_HYPERVISOR_MAGIC 0x564D5868 - -#define VMWARE_CMD_GETVERSION 10 -#define VMWARE_CMD_GETHZ 45 -#define VMWARE_CMD_GETVCPU_INFO 68 -#define VMWARE_CMD_LEGACY_X2APIC 3 -#define VMWARE_CMD_VCPU_RESERVED 31 -#define VMWARE_CMD_STEALCLOCK 91 +#define VCPU_LEGACY_X2APIC 3 +#define VCPU_RESERVED 31 #define STEALCLOCK_NOT_AVAILABLE (-1) #define STEALCLOCK_DISABLED 0 #define STEALCLOCK_ENABLED 1 -#define VMWARE_PORT(cmd, eax, ebx, ecx, edx) \ - __asm__("inl (%%dx), %%eax" : \ - "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \ - "a"(VMWARE_HYPERVISOR_MAGIC), \ - "c"(VMWARE_CMD_##cmd), \ - "d"(VMWARE_HYPERVISOR_PORT), "b"(UINT_MAX) : \ - "memory") - -#define VMWARE_VMCALL(cmd, eax, ebx, ecx, edx) \ - __asm__("vmcall" : \ - "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \ - "a"(VMWARE_HYPERVISOR_MAGIC), \ - "c"(VMWARE_CMD_##cmd), \ - "d"(0), "b"(UINT_MAX) : \ - "memory") - -#define VMWARE_VMMCALL(cmd, eax, ebx, ecx, edx) \ - __asm__("vmmcall" : \ - "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \ - "a"(VMWARE_HYPERVISOR_MAGIC), \ - "c"(VMWARE_CMD_##cmd), \ - "d"(0), "b"(UINT_MAX) : \ - "memory") - -#define VMWARE_CMD(cmd, eax, ebx, ecx, edx) do { \ - switch (vmware_hypercall_mode) { \ - case CPUID_VMWARE_FEATURES_ECX_VMCALL: \ - VMWARE_VMCALL(cmd, eax, ebx, ecx, edx); \ - break; \ - case CPUID_VMWARE_FEATURES_ECX_VMMCALL: \ - VMWARE_VMMCALL(cmd, eax, ebx, ecx, edx); \ - break; \ - default: \ - VMWARE_PORT(cmd, eax, ebx, ecx, edx); \ - break; \ - } \ - } while (0) - struct vmware_steal_time { union { uint64_t clock; /* stolen time counter in units of vtsc */ @@ -108,7 +62,8 @@ struct vmware_steal_time { }; static unsigned long vmware_tsc_khz __ro_after_init; -static u8 vmware_hypercall_mode __ro_after_init; +u8 vmware_hypercall_mode __ro_after_init; +EXPORT_SYMBOL_GPL(vmware_hypercall_mode); static inline int __vmware_platform(void) { @@ -476,8 +431,8 @@ static bool __init vmware_legacy_x2apic_available(void) { uint32_t eax, ebx, ecx, edx; VMWARE_CMD(GETVCPU_INFO, eax, ebx, ecx, edx); - return !(eax & BIT(VMWARE_CMD_VCPU_RESERVED)) && - (eax & BIT(VMWARE_CMD_LEGACY_X2APIC)); + return !(eax & BIT(VCPU_RESERVED)) && + (eax & BIT(VCPU_LEGACY_X2APIC)); } #ifdef CONFIG_AMD_MEM_ENCRYPT From patchwork Fri Dec 1 23:24:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Makhalov X-Patchwork-Id: 749303 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=vmware.com header.i=@vmware.com header.b="XBRX7jbI" Received: from CO1PR02CU001.outbound.protection.outlook.com (mail-westus2azon11011010.outbound.protection.outlook.com [52.101.47.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE0661AD; Fri, 1 Dec 2023 15:25:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kK+n8BnbJ3lEzU1v4eYkiqKlgou6fKoZmZhHqxPzsoA6Zf3896f6A9H2PI0/2ITlyRS+//QEEOmGFLrLNDtwbVRrbM0AlCCxe0tfIbXokpX387d0llGU7Q0DJ6qZwjJn5oUPRq5RVrfRW1CR5ui1u9bperPbvzKQMUfuNNiKH6wC9EIFZlMzbcOMEloNy0J2rFZLKcufLkGQwypW54GA2fscJOskv/tEZyP+o2tfnTW2ZanPn+rU6o3Y8wcWlFCEC64mR4XWdGkFES9En/hOHFU+3hpOzVJfl/3PWE2liAowHyigiZ8cHeCsRveAIRnpqLm+QjOLFgS26URhawB84Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yQMnr6IIrr6r/3xHLijqfAqg6Qi305k2X4S6yputISE=; b=RasGtO2sHYgdD2qbMHqciQCgH5fLKPumunQ3c4eYe4UlL0u5xvjiiW+GqwIklxBzaLBDHaoPvHquV6TJHUg35W++ODT3JmorruCe6+o8odpPppjnsNrsgt5uWTJxETj30LfEbL1dyafXN5L5yvPAWfNH9jqSr4+9FEcqsXg8mokdTLJhudEx0VFypQcIMimhpouYSlGuG1C1dQhZzq1YvVp4vbZwk18ahR2J1/QmCgIUv/yF8YGO7VhmNWDIUjLBx+joYIHqH8p954hNbI0xuXmTGCeo58YMGwNUPJgYLKJpMP8UeTkowhrw4NXlWNqYyq7qwBY4JgrxIbrVVm6uIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yQMnr6IIrr6r/3xHLijqfAqg6Qi305k2X4S6yputISE=; b=XBRX7jbIW4DkQ5qDuOVO8/tPOLBM1H29oOFVTMKOZggTsD3FwfHRcsbEjEqd7+QYzFAdOnruKeIguvXzsq5xYJa3yG/sukb9t0Zpv983JtlKSh4JrCMA09brBSxENiPaMFVQ8RruBAOozGBLwaR6z/BpQRLhz+EHgaXEhGif5io= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vmware.com; Received: from MWHPR05MB3648.namprd05.prod.outlook.com (2603:10b6:301:45::23) by SJ0PR05MB7787.namprd05.prod.outlook.com (2603:10b6:a03:2e4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27; Fri, 1 Dec 2023 23:25:09 +0000 Received: from MWHPR05MB3648.namprd05.prod.outlook.com ([fe80::10f0:590a:708:4ad7]) by MWHPR05MB3648.namprd05.prod.outlook.com ([fe80::10f0:590a:708:4ad7%2]) with mapi id 15.20.7025.021; Fri, 1 Dec 2023 23:25:08 +0000 From: Alexey Makhalov To: linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, hpa@zytor.com, dave.hansen@linux.intel.co, bp@alien8.d, mingo@redhat.com, tglx@linutronix.de Cc: x86@kernel.org, netdev@vger.kernel.org, richardcochran@gmail.com, linux-input@vger.kernel.org, dmitry.torokhov@gmail.com, zackr@vmware.com, linux-graphics-maintainer@vmware.com, pv-drivers@vmware.com, namit@vmware.com, timothym@vmware.com, akaher@vmware.com, jsipek@vmware.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch, airlied@gmail.com, tzimmermann@suse.de, mripard@kernel.org, maarten.lankhorst@linux.intel.com, horms@kernel.org Subject: [PATCH v2 3/6] ptp/vmware: Use vmware_hypercall API Date: Fri, 1 Dec 2023 15:24:49 -0800 Message-Id: <20231201232452.220355-4-amakhalov@vmware.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201232452.220355-1-amakhalov@vmware.com> References: <20231122233058.185601-8-amakhalov@vmware.com> <20231201232452.220355-1-amakhalov@vmware.com> X-ClientProxiedBy: SJ2PR07CA0017.namprd07.prod.outlook.com (2603:10b6:a03:505::17) To MWHPR05MB3648.namprd05.prod.outlook.com (2603:10b6:301:45::23) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR05MB3648:EE_|SJ0PR05MB7787:EE_ X-MS-Office365-Filtering-Correlation-Id: 18e50ccc-7eba-4e90-37f3-08dbf2c4c202 X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtFwd,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jvNaZEq4Qok8L6voJiYOFPKpJzd+4r9/WqWqhvsh5/9XbEHUKtruasq/0N12+rhx1LKFzPhL0tH6oFuyWPFZD44zHMIEdVOvImX8spN01tFJ/6KchWsmuWv7Q4Bt9AACtBGvyhVwi3wLa0+A98xkdTzpI12dpzJznrlZATpTHg9Buc1kLNRaKPZXruP6zgEgsQFbt5EGThFvqYn5fc5efSQ3sX3svKcP1gm8Bnum1Z+saoHS3IE3RzG35BAzdrGDWC10Z5xHxJfil6JmsZNuOFXg5rm/XVOsLyTvW6AVANEKHvY17gDHNNZpqQFeaeXuAakJHyujRK5FcY2pTcX9s9SybCqxxR4NnkQGFwC1KjrBkkiV12BWY/6JbyBbv1PHFYA7wa8l7jCjBCu8tlN6hqByakufFrq2AgYkQBWaUrngph4rRchcpycBzyYJYYwilF4b42JzlXktglHllf1i/2YhU8UNXqmdkK+W6bj98j2+xcVq66xIKmEL5Gly+A2CXUZQWvj5IgaGMfLy0y7jTOhIIk1yT1Xm5TfLKtCNPvtcgeBcdru0zty8UWo+lXutwOz0a1BHBE7U/XO16Qd+S9+15YrZzezya88KGT89S1KoxnenEyOns+HIXY+Y8iEN71IK8T0iwnRQVoRjdx49nOSm9JaO5MGXmS8y/C+bQok= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR05MB3648.namprd05.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(346002)(366004)(376002)(396003)(136003)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(36756003)(8936002)(316002)(66556008)(66946007)(66476007)(8676002)(4326008)(478600001)(6486002)(41300700001)(2906002)(7416002)(86362001)(5660300002)(38350700005)(38100700002)(2616005)(26005)(1076003)(6666004)(6506007)(52116002)(83380400001)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TcQiiocl86W2OYPwgwwXFlHZclGMaWjx6ns+NfwwLbb8ROt+tJMEXoMBXGEn+9FgNGv/RgkkwdGJ3S7PgdzwXGK5JwlifxYmM+uuadjxSs8TeMWWS21tLkXgYwvAk8diIKO+xnNmqvqqojJRI100QwB68IodWWhWy6EKW45ZYUg/vwOc/2qCMZt1rWDKhD3u33CVx86hoD3a3OUi96VixDOGTgEdiawtzAODn9RKcwAsnTZmhvP5BjMg3SEQ6J/Ov+etH3uLj51e/hiDs77HfISHtpoY1n/1BwGdy4z+4DEq+fIVyGiXLSSqcIuQGcHtVlw4URcftk0hgjnJ7m1D0JTtL/zmNQToNH7ysQLAYsOFvqlbnY01XBoCNSdcmB7/rRi6pLWiLLKj3hKi/FLcmN7sZuAhdtTW0MxGZ7ScuxhnrY/cpMifhLOgn+PAny58on3L3ErxgzlaA6M6LLNWeo32snVim5o+lQNIkct362i8jiVQbLBv2/k1xnxU05+1OiGSyUywmYKeK/8G0e5AbhNUNmy90S3iQ45zgYnV3zUCVWjvsvhQz8lrZ+CbnAF/J2JUxZyEk9BpwR9M7ss+pdTX3J/eIxtPiKM48XtB5mgo2xDbcZhDb7hfVn5csVZVVQC/t3vWfkr3HAUKDj3hWxn7sWcH/tcEoFnVK9bGcDy6yfIbRkuiR51HPCUB6SQHW+QjZMyuarJ23DYJPwsS/DmPhTyk9lrVFgBTM3OAYr8vdMJHhhydo3h1vbT0aYyVLQYAN4Z6vUnoS4SWMwHktGfndDhTSPVRbysABe2giMgmvhfknTDtCEzp+s6RGkcm7pxlc4wRDK3RWy4nX6ovarJLrjwiXDb4Lz4rOzuenMEXByI03XmkM9Rzflo1h4BGgkrJlsajQvBHusaNP497X73T+pcT0yw6LBSJEtr5CDzMr+txiNM/gKYwdOpclottzpWN4j3DeR/tgxgxB8irvGaFxLkrOKY2NaWQDSXKgVMApnZZ865PwKYVQnEwkob0o+GrUhCtVqXXClMkw2iKmJq16+ifaySg0Ggq7oF+cJW7IbE864eDq29HVSRZbnmoY6MMiyeNxnW0Pdk57+tx7momPTcujHxzrpRiqfuzauY4InMYJBwTR5vXuI+qmipacs5haY2kS2jq0C9osT4dnonPR7OfwcLIlvIOWDWp/3Vxr8mQKvdPjXEt/MUAv2EQJ1EaTRZRewHbs+HKhYTmDrsNw5ocrdl6BqlTK5e/DlRdMQCpmB6ZstnyPRGn38qfvmlG2NB9fZ2JIMlGIQ3JFd6bU962RlKe4Q0fUtGOrwMTLDylPXRTd4Ji02u01bAhWsvGH6ipP/gjwtmtJzpLWc172mdnCIXScowjnc/iAGM4okUQ/Ex+7SotO8ufSz1hJKYzjBpehsFQ5Gq4nROaLCI3mnW/4ZYFY32XvQxkpteQl0+9UecGTLSke6Zd9JT8MdUe1F9XsHUvlfYcXntnHEqF3k1/I2Rf9LbpLuDlkJQ1EMUSuB/U/Pm0v5s/yFAkcE+RxUHAZY7+buu/2TVNAoLAE1/xQfhaa11BAyJctoJlfOB/2Egai/cInIp6AfES X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18e50ccc-7eba-4e90-37f3-08dbf2c4c202 X-MS-Exchange-CrossTenant-AuthSource: MWHPR05MB3648.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 23:25:08.9204 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FVGT8+3/V/8HueJczbwYKpejP21NGaBGlwdZKNXx0Z2z5N8M7mRlU7zpGssDxenwzv+XbTS0RKx6JAomxWgNdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR05MB7787 Switch from VMWARE_HYPERCALL macro to vmware_hypercall API. Eliminate arch specific code. No functional changes intended. Signed-off-by: Alexey Makhalov Reviewed-by: Nadav Amit Reviewed-by: Jeff Sipek --- drivers/ptp/ptp_vmw.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/ptp/ptp_vmw.c b/drivers/ptp/ptp_vmw.c index 27c5547aa8a9..e5bb521b9b82 100644 --- a/drivers/ptp/ptp_vmw.c +++ b/drivers/ptp/ptp_vmw.c @@ -14,7 +14,6 @@ #include #include -#define VMWARE_MAGIC 0x564D5868 #define VMWARE_CMD_PCLK(nr) ((nr << 16) | 97) #define VMWARE_CMD_PCLK_GETTIME VMWARE_CMD_PCLK(0) @@ -24,15 +23,10 @@ static struct ptp_clock *ptp_vmw_clock; static int ptp_vmw_pclk_read(u64 *ns) { - u32 ret, nsec_hi, nsec_lo, unused1, unused2, unused3; - - asm volatile (VMWARE_HYPERCALL : - "=a"(ret), "=b"(nsec_hi), "=c"(nsec_lo), "=d"(unused1), - "=S"(unused2), "=D"(unused3) : - "a"(VMWARE_MAGIC), "b"(0), - "c"(VMWARE_CMD_PCLK_GETTIME), "d"(0) : - "memory"); + u32 ret, nsec_hi, nsec_lo; + ret = vmware_hypercall3(VMWARE_CMD_PCLK_GETTIME, 0, + &nsec_hi, &nsec_lo); if (ret == 0) *ns = ((u64)nsec_hi << 32) | nsec_lo; return ret; From patchwork Fri Dec 1 23:24:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Makhalov X-Patchwork-Id: 749301 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=vmware.com header.i=@vmware.com header.b="wFZjEral" Received: from CO1PR02CU001.outbound.protection.outlook.com (mail-westus2azon11011010.outbound.protection.outlook.com [52.101.47.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DCB41A6; Fri, 1 Dec 2023 15:25:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WVK9GvyT/R417zBrNA01oSU5fGv/9377ejab8o5OMw20ZjaLyRh7nS2Rc4btBaEEsBby+JX3euz4yMQHlrue9HKF2l4+OKvs/0aGoPtCYFY57ak6W5kBVhMwKA4j0bkQ1cFsOGkkb1WLhUkZeolUd1rMpHaT3lbxBNHSC5kzIcyNdkStPxdOhk7pCbb1Qc66b/zUhk8l6wp67A5uXB/oAypXwAInYnwFYtcYB+NvBpAZaNENzCt0P0jQk1oRo8L9TmXkHN8c0Dqh8lysnH0hGojySdLuqg5e0v7XirTOd9/rLcio4ARlb5t4B1bbgZgwLD1tMVlgoLiOMMT/NNofUg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0qOQp4vCw1n/B0stHkNT+j5TQt26dX3fliNC93hQmv8=; b=V/As/qLIl9heVlG+xkHiV1ibep+fxHgu29QUmFamaUqZsI9rDE5+Mx3lxDc1PV+m0PaNReTblIx0UETMr/r14fl6mf1lD2qVJs7Hz6qA7FVV/XgDB89q6cyHBNt44DgnGwK8lR4CCjgvmZuPfXrBiEmebnhFQHxvic/N/cvWiF9OiQHT+c5tDfQYBwQnmovAa90xb98J/iAdtwqu1UGg+USkcnjHuAPtsePfNNIQENTUpPzQKOJvW7n3Uro5+3bOJQOR1zQsH1KG/iubSrXUOcA8MBXwp14RFMMDkHW18ohqhYB4IIxmZFfM7Z2bSpQcGmt3PWIwQLB30ESLPdp5Pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0qOQp4vCw1n/B0stHkNT+j5TQt26dX3fliNC93hQmv8=; b=wFZjEral4YQ3cz9LDa+LZ4FVjiqtYFvenIQqSL8TfxDZAH0kjMYjWQfRfzoq1TC4mYvb34yfU1QhaFaV7MZ3sQMqq727rl57koOJ/MMiE/m/JckMqP2CyarrFTrhtm/ZD5ne/eMNW9zvhqEfjaBFVvlRMVvHveIJecSNkIdJjQY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vmware.com; Received: from MWHPR05MB3648.namprd05.prod.outlook.com (2603:10b6:301:45::23) by SJ0PR05MB7787.namprd05.prod.outlook.com (2603:10b6:a03:2e4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27; Fri, 1 Dec 2023 23:25:11 +0000 Received: from MWHPR05MB3648.namprd05.prod.outlook.com ([fe80::10f0:590a:708:4ad7]) by MWHPR05MB3648.namprd05.prod.outlook.com ([fe80::10f0:590a:708:4ad7%2]) with mapi id 15.20.7025.021; Fri, 1 Dec 2023 23:25:11 +0000 From: Alexey Makhalov To: linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, hpa@zytor.com, dave.hansen@linux.intel.co, bp@alien8.d, mingo@redhat.com, tglx@linutronix.de Cc: x86@kernel.org, netdev@vger.kernel.org, richardcochran@gmail.com, linux-input@vger.kernel.org, dmitry.torokhov@gmail.com, zackr@vmware.com, linux-graphics-maintainer@vmware.com, pv-drivers@vmware.com, namit@vmware.com, timothym@vmware.com, akaher@vmware.com, jsipek@vmware.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch, airlied@gmail.com, tzimmermann@suse.de, mripard@kernel.org, maarten.lankhorst@linux.intel.com, horms@kernel.org Subject: [PATCH v2 5/6] drm/vmwgfx: Use vmware_hypercall API Date: Fri, 1 Dec 2023 15:24:51 -0800 Message-Id: <20231201232452.220355-6-amakhalov@vmware.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201232452.220355-1-amakhalov@vmware.com> References: <20231122233058.185601-8-amakhalov@vmware.com> <20231201232452.220355-1-amakhalov@vmware.com> X-ClientProxiedBy: SJ2PR07CA0017.namprd07.prod.outlook.com (2603:10b6:a03:505::17) To MWHPR05MB3648.namprd05.prod.outlook.com (2603:10b6:301:45::23) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR05MB3648:EE_|SJ0PR05MB7787:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b5d0077-0360-4de1-13b6-08dbf2c4c363 X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtFwd,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4o/ib0Z9oQcErNMbaNgQnZetEcnk30nu3h5vPGibtDEc8BnbtZ56YRjba31AbxfwfVlOTSJgnsexse3uUAB/Y8tGSWL3uuztcAASl0ZE7+jnnpldmIgnhOBxSy6fUcNfOmtbumOb3DQ4mSR1MnfDWn9gxy86gj6GPeeSAEzCDsV1R8DyNY8mcrvZZHyxWamKdaf2nPgFIqopehE6opcSb0SZj0op8CR5fb6M08aWNCMcjh0CsRPMCXYncPXt5dxpzEWCnrcxqdyAo5avlNvRhodgSSGAM2B1APTH9LfjIp6pRbBYT7wNrjXOdelcVLDpYNE0zZAxCRJKqmceWafbHexD3Yfw+ZZ4+3LZaYLO53y9osqPgIsvDp4eyJs8R135WBWSBu7s4ND8zeRcy+lX3Tk1kBV+5Hxmv+T2W3jcjVYpck1a0OUJT4Xbqzj1XCOCjgVpBFp6Cbi1O19hPUvmOFo/2mblZKviOUFTQ3funJw4Gt95UsCVfsZ24ufulWo5+0mISB9V1B00mtlxq75/W6YtQzrfUS5Dw9gY97vcI6WbRoaLhu30fYLCxwMc4otZo+jMVt8liyOe0irGlcXZFkSH4TxBkx4RnLQlipE2OYnzUykm5luD0ml11tozEpboiuJVSKIe23sFdgeqFD8Hf7YtcvtNHHeRBcGPvhbXU5I= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR05MB3648.namprd05.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(346002)(366004)(376002)(396003)(136003)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(36756003)(8936002)(316002)(66556008)(66946007)(66476007)(8676002)(4326008)(478600001)(6486002)(41300700001)(2906002)(7416002)(86362001)(30864003)(5660300002)(38350700005)(38100700002)(2616005)(26005)(1076003)(6666004)(6506007)(52116002)(83380400001)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xQt2OC3VMOussdwLC4XJKO+Mk52xeKlqcchmYRTXsnzilrriRtg8uyzCgoXBUxUPIBo+o00RdSsbMUIGRueQ0SwzJ8rU0XMassf5JBd2Mw5ovSXkdsKUT3o2oKXNa2qh499P66TOtY4eSRMOzeZu9SKdbRFfsA3ZITUu1/cF46q1QAy5/WM4h9eJo3IkkOub/iUUaMJFUVbhmUn/7thnlpVAwJfj06twpmxRsOTh0fjh0BLEC78Sbc7xih1j3D1CwnTczjgitEWactXNWRGfoMRsaicEW2/kl3TLYSNQ85E8Npa+EmqqwLVBOcOR9W5tXEPHyEu/Vp5cZdDQl8lpnzTCVFw4AfZ5kGjp2sr/0//X9mFURvWoHO0EvJ1QgHc4BcrYSkNQqoLCk6UZgAp7zny7ee0qeE1/6HXF9c5tU8aM2x4ZJQ3ykscbP7lZQ2jyNhcHHA2tXOCJDQoerbEUQJsJGM1gtL7kNZoUlIEDR17u7OBSPZWWVKfrONTtvmnoh4kVQdnTiQerOjfImayePl7P6uRHVI3Tt433xyuIINeTfN4hjwHw0K5FW8vjGS00rwkDFVz943YIGEA0+FP5I05ScOSxjNhKndg6/nGstAL8mGJHokKqAEyf+CJwp4Nwwn9wOsOGPhbd1tGP2hBblfuuQnr681kgVxU6tyM5ev70VF99X65yEDWoJo17eu81pKKcWtBm+PgWpRr0D+33Z/dvFAlsMIZ0JqOtuAv04NYP9QUxRSFPps4j/dJ+OLrz87nwRb55bcKCHDlQCeciEuASSWAZEvTKgA4iSdItF4b1j/YuxhCSQXit8XcsftQAc4edPZXCpNigd7BltTKiZ1nLdN2n/Dghe6fLUob72L8xB+AH7H87fdstATevNQpOd3gqyJy9nqmdZEJn3n8Xf4pDZ3SLL5uyhT8SuyWaVmRraL/OlqkUhZPnVj3nYEl124K0X7R03FySEet2oAWiHcws6GCLcjJDct+HdaalCCrZsX6UcUjnXX1xHlqMevX6vWAWtMCqeGJEjbpfDhz0I5KYZo0FPLoM30edpDdHS5wR2GhVQpwhjsBEP6EazBoHLzrHDRZDeMUv71li8Pk7q7xzBa1RluY97XSJAWOMAlGsnCtcIRgsTUUMZWO6iFX3qXiOZ2THjKCEanU9p5qwrBUsMqw3Iz+rrSFFys0NfMlH3RSBpnfz4IBKKJTlcn4P+dr5IaYhZ4ITcBp2vLR4FHs5Z6BLRKhQiZ/CCH/lrXTqLwH8geHdO0l6hhGt9a0ZQd7N4NpYVhEPj7Wh79QemIsf5fHD5C1QDibNrinxHsDj3d4th/KHuoUk/3scxYxCVTQeCgQENvaFVUiklXXXQDOC+WgE+lIQjoCdLdHVMaEAUodP0o1YSLBOvNo/3/b8r1vejqjDGPKZ7WrW6FhMW+aHrCfKy6PsayvxG80/bL/Vi0/Kigon88zBsYy+l61kAqKgRumEzAU8zxNcEyQZfVNVmFOVpEHI6yt4yb+hogzYm0VRo1xBxYx3p/va1B2+/9Z2cFm+QV79EU+TaJzHwprH8w0FTO//bQhj0s22LWIK1UnFiPxEh0quBBDwH+fj X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b5d0077-0360-4de1-13b6-08dbf2c4c363 X-MS-Exchange-CrossTenant-AuthSource: MWHPR05MB3648.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 23:25:11.1503 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qGu6ZjdOT12EyRk1WP0NkYSTP2kF8PAGjEtoOAwQrO8UWwpJg9jrQW1bG1f0WU9xQUFDHtkx2LNwBZu19jZbbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR05MB7787 Switch from VMWARE_HYPERCALL macro to vmware_hypercall API. Eliminate arch specific code. drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h: implement arm64 variant of vmware_hypercall here for now. The move of these functions to arch/arm64/include/asm/vmware.h as well as removal of drivers/gpu/drm/vmwgfx/vmwgfx_msg_{x86,arm64}.h header files will be performed in the follow up patchset. Signed-off-by: Alexey Makhalov Reviewed-by: Nadav Amit Reviewed-by: Zack Rusin --- drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 173 +++++++------------ drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h | 197 +++++++++++++++------- drivers/gpu/drm/vmwgfx/vmwgfx_msg_x86.h | 185 -------------------- 3 files changed, 197 insertions(+), 358 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c index 2651fe0ef518..1f15990d3934 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c @@ -48,8 +48,6 @@ #define RETRIES 3 -#define VMW_HYPERVISOR_MAGIC 0x564D5868 - #define VMW_PORT_CMD_MSG 30 #define VMW_PORT_CMD_HB_MSG 0 #define VMW_PORT_CMD_OPEN_CHANNEL (MSG_TYPE_OPEN << 16 | VMW_PORT_CMD_MSG) @@ -104,20 +102,18 @@ static const char* const mksstat_kern_name_desc[MKSSTAT_KERN_COUNT][2] = */ static int vmw_open_channel(struct rpc_channel *channel, unsigned int protocol) { - unsigned long eax, ebx, ecx, edx, si = 0, di = 0; + u32 ecx, edx, esi, edi; - VMW_PORT(VMW_PORT_CMD_OPEN_CHANNEL, - (protocol | GUESTMSG_FLAG_COOKIE), si, di, - 0, - VMW_HYPERVISOR_MAGIC, - eax, ebx, ecx, edx, si, di); + vmware_hypercall6(VMW_PORT_CMD_OPEN_CHANNEL, + (protocol | GUESTMSG_FLAG_COOKIE), 0, + &ecx, &edx, &esi, &edi); if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0) return -EINVAL; channel->channel_id = HIGH_WORD(edx); - channel->cookie_high = si; - channel->cookie_low = di; + channel->cookie_high = esi; + channel->cookie_low = edi; return 0; } @@ -133,17 +129,13 @@ static int vmw_open_channel(struct rpc_channel *channel, unsigned int protocol) */ static int vmw_close_channel(struct rpc_channel *channel) { - unsigned long eax, ebx, ecx, edx, si, di; - - /* Set up additional parameters */ - si = channel->cookie_high; - di = channel->cookie_low; + u32 ecx; - VMW_PORT(VMW_PORT_CMD_CLOSE_CHANNEL, - 0, si, di, - channel->channel_id << 16, - VMW_HYPERVISOR_MAGIC, - eax, ebx, ecx, edx, si, di); + vmware_hypercall5(VMW_PORT_CMD_CLOSE_CHANNEL, + 0, channel->channel_id << 16, + channel->cookie_high, + channel->cookie_low, + &ecx); if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0) return -EINVAL; @@ -163,24 +155,18 @@ static int vmw_close_channel(struct rpc_channel *channel) static unsigned long vmw_port_hb_out(struct rpc_channel *channel, const char *msg, bool hb) { - unsigned long si, di, eax, ebx, ecx, edx; + u32 ebx, ecx; unsigned long msg_len = strlen(msg); /* HB port can't access encrypted memory. */ if (hb && !cc_platform_has(CC_ATTR_MEM_ENCRYPT)) { - unsigned long bp = channel->cookie_high; - u32 channel_id = (channel->channel_id << 16); - - si = (uintptr_t) msg; - di = channel->cookie_low; - - VMW_PORT_HB_OUT( + vmware_hypercall_hb_out( (MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG, - msg_len, si, di, - VMWARE_HYPERVISOR_HB | channel_id | - VMWARE_HYPERVISOR_OUT, - VMW_HYPERVISOR_MAGIC, bp, - eax, ebx, ecx, edx, si, di); + msg_len, + channel->channel_id << 16, + (uintptr_t) msg, channel->cookie_low, + channel->cookie_high, + &ebx); return ebx; } @@ -194,14 +180,13 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel, memcpy(&word, msg, bytes); msg_len -= bytes; msg += bytes; - si = channel->cookie_high; - di = channel->cookie_low; - - VMW_PORT(VMW_PORT_CMD_MSG | (MSG_TYPE_SENDPAYLOAD << 16), - word, si, di, - channel->channel_id << 16, - VMW_HYPERVISOR_MAGIC, - eax, ebx, ecx, edx, si, di); + + vmware_hypercall5(VMW_PORT_CMD_MSG | + (MSG_TYPE_SENDPAYLOAD << 16), + word, channel->channel_id << 16, + channel->cookie_high, + channel->cookie_low, + &ecx); } return ecx; @@ -220,22 +205,17 @@ static unsigned long vmw_port_hb_out(struct rpc_channel *channel, static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply, unsigned long reply_len, bool hb) { - unsigned long si, di, eax, ebx, ecx, edx; + u32 ebx, ecx, edx; /* HB port can't access encrypted memory */ if (hb && !cc_platform_has(CC_ATTR_MEM_ENCRYPT)) { - unsigned long bp = channel->cookie_low; - u32 channel_id = (channel->channel_id << 16); - - si = channel->cookie_high; - di = (uintptr_t) reply; - - VMW_PORT_HB_IN( + vmware_hypercall_hb_in( (MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG, - reply_len, si, di, - VMWARE_HYPERVISOR_HB | channel_id, - VMW_HYPERVISOR_MAGIC, bp, - eax, ebx, ecx, edx, si, di); + reply_len, + channel->channel_id << 16, + channel->cookie_high, + (uintptr_t) reply, channel->cookie_low, + &ebx); return ebx; } @@ -245,14 +225,13 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply, while (reply_len) { unsigned int bytes = min_t(unsigned long, reply_len, 4); - si = channel->cookie_high; - di = channel->cookie_low; - - VMW_PORT(VMW_PORT_CMD_MSG | (MSG_TYPE_RECVPAYLOAD << 16), - MESSAGE_STATUS_SUCCESS, si, di, - channel->channel_id << 16, - VMW_HYPERVISOR_MAGIC, - eax, ebx, ecx, edx, si, di); + vmware_hypercall7(VMW_PORT_CMD_MSG | + (MSG_TYPE_RECVPAYLOAD << 16), + MESSAGE_STATUS_SUCCESS, + channel->channel_id << 16, + channel->cookie_high, + channel->cookie_low, + &ebx, &ecx, &edx); if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0) break; @@ -276,22 +255,18 @@ static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply, */ static int vmw_send_msg(struct rpc_channel *channel, const char *msg) { - unsigned long eax, ebx, ecx, edx, si, di; + u32 ebx, ecx; size_t msg_len = strlen(msg); int retries = 0; while (retries < RETRIES) { retries++; - /* Set up additional parameters */ - si = channel->cookie_high; - di = channel->cookie_low; - - VMW_PORT(VMW_PORT_CMD_SENDSIZE, - msg_len, si, di, - channel->channel_id << 16, - VMW_HYPERVISOR_MAGIC, - eax, ebx, ecx, edx, si, di); + vmware_hypercall5(VMW_PORT_CMD_SENDSIZE, + msg_len, channel->channel_id << 16, + channel->cookie_high, + channel->cookie_low, + &ecx); if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0) { /* Expected success. Give up. */ @@ -329,7 +304,7 @@ STACK_FRAME_NON_STANDARD(vmw_send_msg); static int vmw_recv_msg(struct rpc_channel *channel, void **msg, size_t *msg_len) { - unsigned long eax, ebx, ecx, edx, si, di; + u32 ebx, ecx, edx; char *reply; size_t reply_len; int retries = 0; @@ -341,15 +316,11 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg, while (retries < RETRIES) { retries++; - /* Set up additional parameters */ - si = channel->cookie_high; - di = channel->cookie_low; - - VMW_PORT(VMW_PORT_CMD_RECVSIZE, - 0, si, di, - channel->channel_id << 16, - VMW_HYPERVISOR_MAGIC, - eax, ebx, ecx, edx, si, di); + vmware_hypercall7(VMW_PORT_CMD_RECVSIZE, + 0, channel->channel_id << 16, + channel->cookie_high, + channel->cookie_low, + &ebx, &ecx, &edx); if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0) { DRM_ERROR("Failed to get reply size for host message.\n"); @@ -384,16 +355,12 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg, reply[reply_len] = '\0'; - - /* Ack buffer */ - si = channel->cookie_high; - di = channel->cookie_low; - - VMW_PORT(VMW_PORT_CMD_RECVSTATUS, - MESSAGE_STATUS_SUCCESS, si, di, - channel->channel_id << 16, - VMW_HYPERVISOR_MAGIC, - eax, ebx, ecx, edx, si, di); + vmware_hypercall5(VMW_PORT_CMD_RECVSTATUS, + MESSAGE_STATUS_SUCCESS, + channel->channel_id << 16, + channel->cookie_high, + channel->cookie_low, + &ecx); if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0) { kfree(reply); @@ -652,13 +619,7 @@ static inline void reset_ppn_array(PPN64 *arr, size_t size) */ static inline void hypervisor_ppn_reset_all(void) { - unsigned long eax, ebx, ecx, edx, si = 0, di = 0; - - VMW_PORT(VMW_PORT_CMD_MKSGS_RESET, - 0, si, di, - 0, - VMW_HYPERVISOR_MAGIC, - eax, ebx, ecx, edx, si, di); + vmware_hypercall1(VMW_PORT_CMD_MKSGS_RESET, 0); } /** @@ -669,13 +630,7 @@ static inline void hypervisor_ppn_reset_all(void) */ static inline void hypervisor_ppn_add(PPN64 pfn) { - unsigned long eax, ebx, ecx, edx, si = 0, di = 0; - - VMW_PORT(VMW_PORT_CMD_MKSGS_ADD_PPN, - (unsigned long)pfn, si, di, - 0, - VMW_HYPERVISOR_MAGIC, - eax, ebx, ecx, edx, si, di); + vmware_hypercall1(VMW_PORT_CMD_MKSGS_ADD_PPN, (unsigned long)pfn); } /** @@ -686,13 +641,7 @@ static inline void hypervisor_ppn_add(PPN64 pfn) */ static inline void hypervisor_ppn_remove(PPN64 pfn) { - unsigned long eax, ebx, ecx, edx, si = 0, di = 0; - - VMW_PORT(VMW_PORT_CMD_MKSGS_REMOVE_PPN, - (unsigned long)pfn, si, di, - 0, - VMW_HYPERVISOR_MAGIC, - eax, ebx, ecx, edx, si, di); + vmware_hypercall1(VMW_PORT_CMD_MKSGS_REMOVE_PPN, (unsigned long)pfn); } #if IS_ENABLED(CONFIG_DRM_VMWGFX_MKSSTATS) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h b/drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h index 4f40167ad61f..29bd0af83038 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h @@ -34,6 +34,8 @@ #define VMWARE_HYPERVISOR_HB BIT(0) #define VMWARE_HYPERVISOR_OUT BIT(1) +#define VMWARE_HYPERVISOR_MAGIC 0x564D5868 + #define X86_IO_MAGIC 0x86 #define X86_IO_W7_SIZE_SHIFT 0 @@ -45,86 +47,159 @@ #define X86_IO_W7_IMM_SHIFT 5 #define X86_IO_W7_IMM_MASK (0xff << X86_IO_W7_IMM_SHIFT) -static inline void vmw_port(unsigned long cmd, unsigned long in_ebx, - unsigned long in_si, unsigned long in_di, - unsigned long flags, unsigned long magic, - unsigned long *eax, unsigned long *ebx, - unsigned long *ecx, unsigned long *edx, - unsigned long *si, unsigned long *di) +static inline +unsigned long vmware_hypercall1(unsigned long cmd, unsigned long in1) { - register u64 x0 asm("x0") = magic; - register u64 x1 asm("x1") = in_ebx; + register u64 x0 asm("x0") = VMWARE_HYPERVISOR_MAGIC; + register u64 x1 asm("x1") = in1; register u64 x2 asm("x2") = cmd; - register u64 x3 asm("x3") = flags | VMWARE_HYPERVISOR_PORT; - register u64 x4 asm("x4") = in_si; - register u64 x5 asm("x5") = in_di; + register u64 x3 asm("x3") = VMWARE_HYPERVISOR_PORT; + register u64 x7 asm("x7") = ((u64)X86_IO_MAGIC << 32) | + X86_IO_W7_WITH | + X86_IO_W7_DIR | + (2 << X86_IO_W7_SIZE_SHIFT); + asm_inline volatile ( + "mrs xzr, mdccsr_el0; " + : "+r" (x0) + : "r" (x1), "r" (x2), "r" (x3), "r" (x7) + : "memory"); + + return x0; +} + +static inline +unsigned long vmware_hypercall5(unsigned long cmd, unsigned long in1, + unsigned long in3, unsigned long in4, + unsigned long in5, uint32_t *out2) +{ + register u64 x0 asm("x0") = VMWARE_HYPERVISOR_MAGIC; + register u64 x1 asm("x1") = in1; + register u64 x2 asm("x2") = cmd; + register u64 x3 asm("x3") = in3 | VMWARE_HYPERVISOR_PORT; + register u64 x4 asm("x4") = in4; + register u64 x5 asm("x5") = in5; register u64 x7 asm("x7") = ((u64)X86_IO_MAGIC << 32) | X86_IO_W7_WITH | X86_IO_W7_DIR | (2 << X86_IO_W7_SIZE_SHIFT); - asm volatile("mrs xzr, mdccsr_el0 \n\t" - : "+r"(x0), "+r"(x1), "+r"(x2), - "+r"(x3), "+r"(x4), "+r"(x5) - : "r"(x7) - :); - *eax = x0; - *ebx = x1; - *ecx = x2; - *edx = x3; - *si = x4; - *di = x5; + asm_inline volatile ( + "mrs xzr, mdccsr_el0; " + : "+r" (x0), "+r" (x2) + : "r" (x1), "r" (x3), "r" (x4), "r" (x5), "r" (x7) + : "memory"); + + *out2 = x2; + return x0; } -static inline void vmw_port_hb(unsigned long cmd, unsigned long in_ecx, - unsigned long in_si, unsigned long in_di, - unsigned long flags, unsigned long magic, - unsigned long bp, u32 w7dir, - unsigned long *eax, unsigned long *ebx, - unsigned long *ecx, unsigned long *edx, - unsigned long *si, unsigned long *di) +static inline +unsigned long vmware_hypercall6(unsigned long cmd, unsigned long in1, + unsigned long in3, uint32_t *out2, + uint32_t *out3, uint32_t *out4, + uint32_t *out5) { - register u64 x0 asm("x0") = magic; + register u64 x0 asm("x0") = VMWARE_HYPERVISOR_MAGIC; + register u64 x1 asm("x1") = in1; + register u64 x2 asm("x2") = cmd; + register u64 x3 asm("x3") = in3 | VMWARE_HYPERVISOR_PORT; + register u64 x4 asm("x4"); + register u64 x5 asm("x5"); + register u64 x7 asm("x7") = ((u64)X86_IO_MAGIC << 32) | + X86_IO_W7_WITH | + X86_IO_W7_DIR | + (2 << X86_IO_W7_SIZE_SHIFT); + + asm_inline volatile ( + "mrs xzr, mdccsr_el0; " + : "+r" (x0), "+r" (x2), "+r" (x3), "=r" (x4), "=r" (x5) + : "r" (x1), "r" (x7) + : "memory"); + + *out2 = x2; + *out3 = x3; + *out4 = x4; + *out5 = x5; + return x0; +} + +static inline +unsigned long vmware_hypercall7(unsigned long cmd, unsigned long in1, + unsigned long in3, unsigned long in4, + unsigned long in5, uint32_t *out1, + uint32_t *out2, uint32_t *out3) +{ + register u64 x0 asm("x0") = VMWARE_HYPERVISOR_MAGIC; + register u64 x1 asm("x1") = in1; + register u64 x2 asm("x2") = cmd; + register u64 x3 asm("x3") = in3 | VMWARE_HYPERVISOR_PORT; + register u64 x4 asm("x4") = in4; + register u64 x5 asm("x5") = in5; + register u64 x7 asm("x7") = ((u64)X86_IO_MAGIC << 32) | + X86_IO_W7_WITH | + X86_IO_W7_DIR | + (2 << X86_IO_W7_SIZE_SHIFT); + + asm_inline volatile ( + "mrs xzr, mdccsr_el0; " + : "+r" (x0), "+r" (x1), "+r" (x2), "+r" (x3) + : "r" (x4), "r" (x5), "r" (x7) + : "memory"); + + *out1 = x1; + *out2 = x2; + *out3 = x3; + return x0; +} + +static inline +unsigned long vmware_hypercall_hb(unsigned long cmd, unsigned long in2, + unsigned long in3, unsigned long in4, + unsigned long in5, unsigned long in6, + uint32_t *out1, int dir) +{ + register u64 x0 asm("x0") = VMWARE_HYPERVISOR_MAGIC; register u64 x1 asm("x1") = cmd; - register u64 x2 asm("x2") = in_ecx; - register u64 x3 asm("x3") = flags | VMWARE_HYPERVISOR_PORT_HB; - register u64 x4 asm("x4") = in_si; - register u64 x5 asm("x5") = in_di; - register u64 x6 asm("x6") = bp; + register u64 x2 asm("x2") = in2; + register u64 x3 asm("x3") = in3 | VMWARE_HYPERVISOR_PORT_HB; + register u64 x4 asm("x4") = in4; + register u64 x5 asm("x5") = in5; + register u64 x6 asm("x6") = in6; register u64 x7 asm("x7") = ((u64)X86_IO_MAGIC << 32) | X86_IO_W7_STR | X86_IO_W7_WITH | - w7dir; - - asm volatile("mrs xzr, mdccsr_el0 \n\t" - : "+r"(x0), "+r"(x1), "+r"(x2), - "+r"(x3), "+r"(x4), "+r"(x5) - : "r"(x6), "r"(x7) - :); - *eax = x0; - *ebx = x1; - *ecx = x2; - *edx = x3; - *si = x4; - *di = x5; -} + dir; -#define VMW_PORT(cmd, in_ebx, in_si, in_di, flags, magic, eax, ebx, ecx, edx, \ - si, di) \ - vmw_port(cmd, in_ebx, in_si, in_di, flags, magic, &eax, &ebx, &ecx, \ - &edx, &si, &di) + asm_inline volatile ( + "mrs xzr, mdccsr_el0; " + : "+r" (x0), "+r" (x1) + : "r" (x2), "r" (x3), "r" (x4), "r" (x5), + "r" (x6), "r" (x7) + : "memory"); -#define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, flags, magic, bp, eax, ebx, \ - ecx, edx, si, di) \ - vmw_port_hb(cmd, in_ecx, in_si, in_di, flags, magic, bp, \ - 0, &eax, &ebx, &ecx, &edx, &si, &di) + *out1 = x1; + return x0; +} -#define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, flags, magic, bp, eax, ebx, \ - ecx, edx, si, di) \ - vmw_port_hb(cmd, in_ecx, in_si, in_di, flags, magic, bp, \ - X86_IO_W7_DIR, &eax, &ebx, &ecx, &edx, &si, &di) +static inline +unsigned long vmware_hypercall_hb_out(unsigned long cmd, unsigned long in2, + unsigned long in3, unsigned long in4, + unsigned long in5, unsigned long in6, + uint32_t *out1) +{ + return vmware_hypercall_hb(cmd, in2, in3, in4, in5, in6, out1, 0); +} +static inline +unsigned long vmware_hypercall_hb_in(unsigned long cmd, unsigned long in2, + unsigned long in3, unsigned long in4, + unsigned long in5, unsigned long in6, + uint32_t *out1) +{ + return vmware_hypercall_hb(cmd, in2, in3, in4, in5, in6, out1, + X86_IO_W7_DIR); +} #endif #endif /* _VMWGFX_MSG_ARM64_H */ diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg_x86.h b/drivers/gpu/drm/vmwgfx/vmwgfx_msg_x86.h index 23899d743a90..13304d34cc6e 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg_x86.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg_x86.h @@ -37,191 +37,6 @@ #include -/** - * Hypervisor-specific bi-directional communication channel. Should never - * execute on bare metal hardware. The caller must make sure to check for - * supported hypervisor before using these macros. - * - * The last two parameters are both input and output and must be initialized. - * - * @cmd: [IN] Message Cmd - * @in_ebx: [IN] Message Len, through EBX - * @in_si: [IN] Input argument through SI, set to 0 if not used - * @in_di: [IN] Input argument through DI, set ot 0 if not used - * @flags: [IN] hypercall flags + [channel id] - * @magic: [IN] hypervisor magic value - * @eax: [OUT] value of EAX register - * @ebx: [OUT] e.g. status from an HB message status command - * @ecx: [OUT] e.g. status from a non-HB message status command - * @edx: [OUT] e.g. channel id - * @si: [OUT] - * @di: [OUT] - */ -#define VMW_PORT(cmd, in_ebx, in_si, in_di, \ - flags, magic, \ - eax, ebx, ecx, edx, si, di) \ -({ \ - asm volatile (VMWARE_HYPERCALL : \ - "=a"(eax), \ - "=b"(ebx), \ - "=c"(ecx), \ - "=d"(edx), \ - "=S"(si), \ - "=D"(di) : \ - "a"(magic), \ - "b"(in_ebx), \ - "c"(cmd), \ - "d"(flags), \ - "S"(in_si), \ - "D"(in_di) : \ - "memory"); \ -}) - - -/** - * Hypervisor-specific bi-directional communication channel. Should never - * execute on bare metal hardware. The caller must make sure to check for - * supported hypervisor before using these macros. - * - * The last 3 parameters are both input and output and must be initialized. - * - * @cmd: [IN] Message Cmd - * @in_ecx: [IN] Message Len, through ECX - * @in_si: [IN] Input argument through SI, set to 0 if not used - * @in_di: [IN] Input argument through DI, set to 0 if not used - * @flags: [IN] hypercall flags + [channel id] - * @magic: [IN] hypervisor magic value - * @bp: [IN] - * @eax: [OUT] value of EAX register - * @ebx: [OUT] e.g. status from an HB message status command - * @ecx: [OUT] e.g. status from a non-HB message status command - * @edx: [OUT] e.g. channel id - * @si: [OUT] - * @di: [OUT] - */ -#ifdef __x86_64__ - -#define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \ - flags, magic, bp, \ - eax, ebx, ecx, edx, si, di) \ -({ \ - asm volatile ( \ - UNWIND_HINT_SAVE \ - "push %%rbp;" \ - UNWIND_HINT_UNDEFINED \ - "mov %12, %%rbp;" \ - VMWARE_HYPERCALL_HB_OUT \ - "pop %%rbp;" \ - UNWIND_HINT_RESTORE : \ - "=a"(eax), \ - "=b"(ebx), \ - "=c"(ecx), \ - "=d"(edx), \ - "=S"(si), \ - "=D"(di) : \ - "a"(magic), \ - "b"(cmd), \ - "c"(in_ecx), \ - "d"(flags), \ - "S"(in_si), \ - "D"(in_di), \ - "r"(bp) : \ - "memory", "cc"); \ -}) - - -#define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, \ - flags, magic, bp, \ - eax, ebx, ecx, edx, si, di) \ -({ \ - asm volatile ( \ - UNWIND_HINT_SAVE \ - "push %%rbp;" \ - UNWIND_HINT_UNDEFINED \ - "mov %12, %%rbp;" \ - VMWARE_HYPERCALL_HB_IN \ - "pop %%rbp;" \ - UNWIND_HINT_RESTORE : \ - "=a"(eax), \ - "=b"(ebx), \ - "=c"(ecx), \ - "=d"(edx), \ - "=S"(si), \ - "=D"(di) : \ - "a"(magic), \ - "b"(cmd), \ - "c"(in_ecx), \ - "d"(flags), \ - "S"(in_si), \ - "D"(in_di), \ - "r"(bp) : \ - "memory", "cc"); \ -}) - -#elif defined(__i386__) - -/* - * In the 32-bit version of this macro, we store bp in a memory location - * because we've ran out of registers. - * Now we can't reference that memory location while we've modified - * %esp or %ebp, so we first push it on the stack, just before we push - * %ebp, and then when we need it we read it from the stack where we - * just pushed it. - */ -#define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \ - flags, magic, bp, \ - eax, ebx, ecx, edx, si, di) \ -({ \ - asm volatile ("push %12;" \ - "push %%ebp;" \ - "mov 0x04(%%esp), %%ebp;" \ - VMWARE_HYPERCALL_HB_OUT \ - "pop %%ebp;" \ - "add $0x04, %%esp;" : \ - "=a"(eax), \ - "=b"(ebx), \ - "=c"(ecx), \ - "=d"(edx), \ - "=S"(si), \ - "=D"(di) : \ - "a"(magic), \ - "b"(cmd), \ - "c"(in_ecx), \ - "d"(flags), \ - "S"(in_si), \ - "D"(in_di), \ - "m"(bp) : \ - "memory", "cc"); \ -}) - - -#define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, \ - flags, magic, bp, \ - eax, ebx, ecx, edx, si, di) \ -({ \ - asm volatile ("push %12;" \ - "push %%ebp;" \ - "mov 0x04(%%esp), %%ebp;" \ - VMWARE_HYPERCALL_HB_IN \ - "pop %%ebp;" \ - "add $0x04, %%esp;" : \ - "=a"(eax), \ - "=b"(ebx), \ - "=c"(ecx), \ - "=d"(edx), \ - "=S"(si), \ - "=D"(di) : \ - "a"(magic), \ - "b"(cmd), \ - "c"(in_ecx), \ - "d"(flags), \ - "S"(in_si), \ - "D"(in_di), \ - "m"(bp) : \ - "memory", "cc"); \ -}) -#endif /* defined(__i386__) */ - #endif /* defined(__i386__) || defined(__x86_64__) */ #endif /* _VMWGFX_MSG_X86_H */