Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1265868lqs; Sat, 15 Jun 2024 01:22:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfXdHhABl3fFwO7KLuK6ospgthHP9YAzZjOYMvejOPo0YtxesKUkiAP5IrduC2GCoL9HLEiknJThzpncmZbbg+7SdhSs9U3PAXqJ+JRw== X-Google-Smtp-Source: AGHT+IFmHDhaNXeWjG1K3xDtuakZsPkkUDEBcesTmnG/AxxMTcZTZVb5CXaCVQGcB1PLfdRGc6B2 X-Received: by 2002:a17:90a:4a0e:b0:2c2:c3f5:33c3 with SMTP id 98e67ed59e1d1-2c4bd8ace45mr11722029a91.6.1718439769096; Sat, 15 Jun 2024 01:22:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718439769; cv=pass; d=google.com; s=arc-20160816; b=NBG1mOiKbFiCpkTJbc9uNRaQZtjlp+8xrVRPuN98u9+4g2huhgaFXJxW+FlpUk4i5i 7ya6qJAtfi6dtVY7Hipx7uAdgtxvNavZaIkqPx+p+ZFAnbyQeduo0ZExM16eaFvvMl4E osZxU6oA/rC0n03eP0GTgxbE/TWT2jcQ5LozYqa+mk2IuLTVsCgscP3Si6xDLYHn29jQ kkW6ILJ9Jcv5aObF+8t7WJpmDZ8zJhKeeAnYeE1t7mzVjCnQKK2wfUcFb1ONheu0/qQy xp9Svf1mPCr9uZqJRtM15IFpTZwXWDBxqkAIFmmVJdpfmx1e/gqQubXEgMapQ6TJXFt8 Qo/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=hi+iuZbBG5CrzEvxSBw8hpeL4wrSnAwsSXvpC7QCq1o=; fh=NRl/XtS3teoHzFUks/oVv9Fyib+ZuFvDaG7V6BY7BZE=; b=UpnSv0QZMJ1AEkIFcJoyPqIoLXiXdDMQ3gS71G00TVvzq2m20BkatLE2OuoqL+TRoS +5kokyvIMJrQaatHPpJRQ3QYgnqVeEcM7uRSjmhRUftZnek5zXQCftewHbbUxlBUYZRU WDHkPpd0BncKOfyWZ16/CesiE57Vs5w3IyGeiLY6oqB0EQuz+DctTV5QU6gU2G6OCAtm yEaf1pmJDQPpRFKJ9FFivVY3dM2uOcKqUKWaGyVwVMM0J8t7ZikJuOvQZhlGTe7yD1z4 D1iEbupflJi0KpRgxU4R/n+UQomm9CMOsrMB1KsuNu5TamhuClWZrT3C6gnt0ZtYcUBQ /6gQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XUBcSqF8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-215780-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4a76e8cb1si7189954a91.157.2024.06.15.01.22.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jun 2024 01:22:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215780-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XUBcSqF8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-215780-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D0B9F283ACE for ; Sat, 15 Jun 2024 08:22:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2076722313; Sat, 15 Jun 2024 08:21:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="XUBcSqF8"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="iJ5neK9i" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 471BA199C2; Sat, 15 Jun 2024 08:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718439710; cv=none; b=qDkqTgkyc95qx8l/St0fSTjJSpg3YPk5VPsxpQWZvZi4IHRnjls8mAOLDI9CHfwTa1iRBwyJWPcW8tNNADht+8AR+q8rJ3A08kPLQJWw4/dIi5Uy2rASopZXO+CwQ3DvOzOoFN6IC+gNzpV81LHC25i3nSDeKr8n2tS7yZPqvhY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718439710; c=relaxed/simple; bh=MJYZZefTCDk1ATfAdI+AWfaeji0J/ybGcK0EAGTDdT4=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=qohKm+UgnXDdu+bjbvS0Owh6oCbjDpYgiUiOFroe9JhyRBP+3hOykZ4bemcJ8LrmLR2Nym5MTmbdFqWLA/cBMV1yA7alnSiPo3nyX3dbMSHmPVwssY5coPt76QvS3Y6GpOLuB2EWmkUUtMP4pr0tymi9xBmJ59siNFfN2qHmiqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=XUBcSqF8; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=iJ5neK9i; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Sat, 15 Jun 2024 08:21:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718439706; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hi+iuZbBG5CrzEvxSBw8hpeL4wrSnAwsSXvpC7QCq1o=; b=XUBcSqF8utnK9FOZzRGcyOMJVkf68SPEibRyBzdqPsjiQ7JX4Ftzcn6Ufj6wtja2exivpt VvA42qbnVawwBAA4TesOwhXOwB8YlUr3NOydDrbqF+Yv8/Oy/hLgp0T52xHtUd+hS4q/k5 H4qiPcahQwPYtU9C3DJleue9U/cz5eEut0eGkq7Su98GXb6LTQ0rYCc+bxjXCK65XRy4Cx nPqO13bRuSoh+xerG48pkgnMr6R82EX6ms1CZ/iU5ehcMAA2Ruf44eCfr4aSJa8LI/RFsB LJsxA8HlZ+NbSRYc1K4gicZqw3xpBehIglZ3m7axkVnghhR/lDFkn2wDrT+11Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718439706; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hi+iuZbBG5CrzEvxSBw8hpeL4wrSnAwsSXvpC7QCq1o=; b=iJ5neK9ieqxtnJ+cSSXbn147ZaXqD+BvjWRuGGc84p/IP8Jx/VqwKvYc9w7xSZd0XsTROt j0Lzy3PBfJq+VeCg== From: "tip-bot2 for Alexey Makhalov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/vmware] x86/vmware: Use VMware hypercall API Cc: Alexey Makhalov , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240613191650.9913-6-alexey.makhalov@broadcom.com> References: <20240613191650.9913-6-alexey.makhalov@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171843970608.10875.6339557038367198942.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/vmware branch of tip: Commit-ID: 986fd97b9cc45fda0810b763ea403d0f280a4ac5 Gitweb: https://git.kernel.org/tip/986fd97b9cc45fda0810b763ea403d0f280a4ac5 Author: Alexey Makhalov AuthorDate: Thu, 13 Jun 2024 12:16:47 -07:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 14 Jun 2024 18:01:21 +02:00 x86/vmware: Use VMware hypercall API Remove VMWARE_CMD macro and move to vmware_hypercall API. No functional changes intended. Use u32/u64 instead of uint32_t/uint64_t across the file. Signed-off-by: Alexey Makhalov Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20240613191650.9913-6-alexey.makhalov@broadcom.com --- arch/x86/kernel/cpu/vmware.c | 95 +++++++++-------------------------- 1 file changed, 25 insertions(+), 70 deletions(-) diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c index 533ac2d..c0a3ffa 100644 --- a/arch/x86/kernel/cpu/vmware.c +++ b/arch/x86/kernel/cpu/vmware.c @@ -49,54 +49,16 @@ #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 */ + u64 clock; /* stolen time counter in units of vtsc */ struct { /* only for little-endian */ - uint32_t clock_low; - uint32_t clock_high; + u32 clock_low; + u32 clock_high; }; }; - uint64_t reserved[7]; + u64 reserved[7]; }; static unsigned long vmware_tsc_khz __ro_after_init; @@ -154,9 +116,10 @@ unsigned long vmware_hypercall_slow(unsigned long cmd, static inline int __vmware_platform(void) { - uint32_t eax, ebx, ecx, edx; - VMWARE_CMD(GETVERSION, eax, ebx, ecx, edx); - return eax != (uint32_t)-1 && ebx == VMWARE_HYPERVISOR_MAGIC; + u32 eax, ebx, ecx; + + eax = vmware_hypercall3(VMWARE_CMD_GETVERSION, 0, &ebx, &ecx); + return eax != UINT_MAX && ebx == VMWARE_HYPERVISOR_MAGIC; } static unsigned long vmware_get_tsc_khz(void) @@ -208,21 +171,12 @@ static void __init vmware_cyc2ns_setup(void) pr_info("using clock offset of %llu ns\n", d->cyc2ns_offset); } -static int vmware_cmd_stealclock(uint32_t arg1, uint32_t arg2) +static int vmware_cmd_stealclock(u32 addr_hi, u32 addr_lo) { - uint32_t result, info; - - asm volatile (VMWARE_HYPERCALL : - "=a"(result), - "=c"(info) : - "a"(VMWARE_HYPERVISOR_MAGIC), - "b"(0), - "c"(VMWARE_CMD_STEALCLOCK), - "d"(0), - "S"(arg1), - "D"(arg2) : - "memory"); - return result; + u32 info; + + return vmware_hypercall5(VMWARE_CMD_STEALCLOCK, 0, 0, addr_hi, addr_lo, + &info); } static bool stealclock_enable(phys_addr_t pa) @@ -257,15 +211,15 @@ static bool vmware_is_stealclock_available(void) * Return: * The steal clock reading in ns. */ -static uint64_t vmware_steal_clock(int cpu) +static u64 vmware_steal_clock(int cpu) { struct vmware_steal_time *steal = &per_cpu(vmw_steal_time, cpu); - uint64_t clock; + u64 clock; if (IS_ENABLED(CONFIG_64BIT)) clock = READ_ONCE(steal->clock); else { - uint32_t initial_high, low, high; + u32 initial_high, low, high; do { initial_high = READ_ONCE(steal->clock_high); @@ -277,7 +231,7 @@ static uint64_t vmware_steal_clock(int cpu) high = READ_ONCE(steal->clock_high); } while (initial_high != high); - clock = ((uint64_t)high << 32) | low; + clock = ((u64)high << 32) | low; } return mul_u64_u32_shr(clock, vmware_cyc2ns.cyc2ns_mul, @@ -431,13 +385,13 @@ static void __init vmware_set_capabilities(void) static void __init vmware_platform_setup(void) { - uint32_t eax, ebx, ecx, edx; - uint64_t lpj, tsc_khz; + u32 eax, ebx, ecx; + u64 lpj, tsc_khz; - VMWARE_CMD(GETHZ, eax, ebx, ecx, edx); + eax = vmware_hypercall3(VMWARE_CMD_GETHZ, UINT_MAX, &ebx, &ecx); if (ebx != UINT_MAX) { - lpj = tsc_khz = eax | (((uint64_t)ebx) << 32); + lpj = tsc_khz = eax | (((u64)ebx) << 32); do_div(tsc_khz, 1000); WARN_ON(tsc_khz >> 32); pr_info("TSC freq read from hypervisor : %lu.%03lu MHz\n", @@ -488,7 +442,7 @@ static u8 __init vmware_select_hypercall(void) * If !boot_cpu_has(X86_FEATURE_HYPERVISOR), vmware_hypercall_mode * intentionally defaults to 0. */ -static uint32_t __init vmware_platform(void) +static u32 __init vmware_platform(void) { if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) { unsigned int eax; @@ -516,8 +470,9 @@ static uint32_t __init vmware_platform(void) /* Checks if hypervisor supports x2apic without VT-D interrupt remapping. */ static bool __init vmware_legacy_x2apic_available(void) { - uint32_t eax, ebx, ecx, edx; - VMWARE_CMD(GETVCPU_INFO, eax, ebx, ecx, edx); + u32 eax; + + eax = vmware_hypercall1(VMWARE_CMD_GETVCPU_INFO, 0); return !(eax & BIT(VMWARE_CMD_VCPU_RESERVED)) && (eax & BIT(VMWARE_CMD_LEGACY_X2APIC)); }