Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1266052lqs; Sat, 15 Jun 2024 01:23:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXtEH429Ts/jD/SQighUoAMCR7B+vh3NgWfSXM5kU43+ubBVVXVZpw31UDzoN0CU6RGnNaO3rknEEu6sNY0KAf7Yys0Zwj5CvRYwjzYxw== X-Google-Smtp-Source: AGHT+IFEOZ6hOVaxxpNMQd0VFXHahq8loTEz/NCqKOS9mqx6XGUO5FCi5fxgFSwEJAVVX0G55qbL X-Received: by 2002:a17:907:868d:b0:a6f:6ef:225 with SMTP id a640c23a62f3a-a6f60d2054dmr402676866b.19.1718439816809; Sat, 15 Jun 2024 01:23:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718439816; cv=pass; d=google.com; s=arc-20160816; b=MuGrliNxW+a38wkPmMY+6gzW2DdBCSoWicj+ZVb2DlCogapjGZdzyumeHrG7gct8K2 RYL0y26c0oRaZcIqaN1BTZRi0iJ+uWFxsoeWCQuKFhFpMQ+uyBkV0wn0+2h1OnsDP7Tc bRuI8wZG21bdwO3oVmRhNFc2AlX91W+vDupgr2ZUe1JM47uJMBA8GmodreVTiMP0ZhKx /Xrtv72GT+gZbp3OFcaOWcQsZg/HolpyTJ0kt4eQSVRcN3gyJKQuIuOE350nW48cgs0E ++8+ymORZC6FuwF3WKo2n+QSgz96/UnpzKI+7PXn+CCqQ6sgeAKYJm5GL+NXDN38Burs PfcA== 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=D9ospV/QiWJ0FpmAo7z16Apo/RC3Sbx9WPHk6QKEUbY=; fh=NRl/XtS3teoHzFUks/oVv9Fyib+ZuFvDaG7V6BY7BZE=; b=OCSiTk9YqzBMdHZuJFp7t1nbC+Zr8Co/gNdx2ME4Y3QGkqr/Wn1MA6EkJg2IpN3mgr vrX/DvYrBNCx4RRoaxLdDRgkhvmjZsDjA75u6/FsmfMe7Z3Hd5TrsUZFi1wLFFKP53EM rwv1idfMidpTVPr6PVKhNbGxra5fTpfI/PklLmb/Djku1tXKLy43al05JAXk5eoAXgv7 YbmEVj2rW70OWhEB6r75JhlNRRMLab5Ka2tiTrvnsSDT4xbOahfGqourj61h0gpP2hNK 65ZLBy+R0fkrgBRHgWlb55Mzgi5s/3esArJ8jYQfNa/J4v0egGhB2/Z7s3KJYuwWVEiM 1W1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="uJyo/IWO"; 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-215784-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215784-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56e262f6si256515566b.715.2024.06.15.01.23.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jun 2024 01:23:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215784-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="uJyo/IWO"; 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-215784-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215784-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 553E11F23DC6 for ; Sat, 15 Jun 2024 08:23:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA8473A1B6; Sat, 15 Jun 2024 08:21:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="uJyo/IWO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8c74tBaP" 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 D9302208D1; Sat, 15 Jun 2024 08:21:50 +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=1718439712; cv=none; b=Wt0UZ0zlRJlnowoKOMo42nYNVLtKpoqLHRPz3WM1j0WBB7HZK63zl6O3nZWR/toG2EPyZwFzGrG2DTCbcMPXcuuuwSfePNVTa/GOipVVMTIGLynkWhFD4/xlu6NFc8SVdr7tHhRXUNEJdk7DJKZoRUOvRvjUTWrI5mqqPNPAlMs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718439712; c=relaxed/simple; bh=mzl5gNugTkTmCVPf5YsIDhBYvpYmunAu2b/pieB11Fc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=OJG0G3vEFTpI7XCGMBD1iP/nqyKYbK9RspcnULkptJ4TttDF9UGOclUzylfYT2/GB0pkvYkLfJ2zVWTEzrfyaZO+3noLq6PFDld4t+X2wW5c8f7GTaXCwJXSwOnAo6hf4xk+wTRVQ3OppgOq6BlBLior+fSEcvuh9gF1HIOwT6s= 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=uJyo/IWO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=8c74tBaP; 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=D9ospV/QiWJ0FpmAo7z16Apo/RC3Sbx9WPHk6QKEUbY=; b=uJyo/IWOneF8v0kOJttkJHmB+0kozYCGiNrnc6sk2nc36124B042ijxnjiOQ6r+SNf8Tyj M11/QgeETcpoxWknPUdBbYjvydcoHE4WHT1mMcOulC/1F4WREKq0E39ZXYZFlugeiVudRu pgPdW4eKJ9Kw+kummRZl12IbAxtIiSeSPdTM4FNnlX3/ElIE2+o3un6UPLhh7tqrSO5H9X xPoQGuSlh/e+QDrrphDuVRoAhKBWlYCUVcbXfhq57dqsxasKMDS6n2smV1G7XqNb7/EVdx fttui7M5mZLTQenQTqmwdY4E5bsGpJya1KUU+QCCEZE4c4qJObfSm/HgpA9RCw== 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=D9ospV/QiWJ0FpmAo7z16Apo/RC3Sbx9WPHk6QKEUbY=; b=8c74tBaP1F0ON/vxk6zUMs1pty/zR6ZbCIw0tDs61Fq5gyMjS3k34qEV5JRsT7HAE8ucHn fSzihK6CA/3sSWAg== 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] input/vmmouse: Use VMware hypercall API Cc: Alexey Makhalov , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240613191650.9913-4-alexey.makhalov@broadcom.com> References: <20240613191650.9913-4-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: <171843970646.10875.11154402288451406057.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: 2f55c98aae584ee560dedbb5cb498e7ab96a40b2 Gitweb: https://git.kernel.org/tip/2f55c98aae584ee560dedbb5cb498e7ab96a40b2 Author: Alexey Makhalov AuthorDate: Thu, 13 Jun 2024 12:16:45 -07:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 14 Jun 2024 18:01:21 +02:00 input/vmmouse: Use VMware hypercall API Switch from VMWARE_HYPERCALL macro to vmware_hypercall API. Eliminate arch specific code. No functional changes intended. Signed-off-by: Alexey Makhalov Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20240613191650.9913-4-alexey.makhalov@broadcom.com --- drivers/input/mouse/vmmouse.c | 76 +++++++++------------------------- 1 file changed, 22 insertions(+), 54 deletions(-) diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c index ea9eff7..fb1d986 100644 --- a/drivers/input/mouse/vmmouse.c +++ b/drivers/input/mouse/vmmouse.c @@ -21,19 +21,16 @@ #include "psmouse.h" #include "vmmouse.h" -#define VMMOUSE_PROTO_MAGIC 0x564D5868U - /* * Main commands supported by the vmmouse hypervisor port. */ -#define VMMOUSE_PROTO_CMD_GETVERSION 10 -#define VMMOUSE_PROTO_CMD_ABSPOINTER_DATA 39 -#define VMMOUSE_PROTO_CMD_ABSPOINTER_STATUS 40 -#define VMMOUSE_PROTO_CMD_ABSPOINTER_COMMAND 41 -#define VMMOUSE_PROTO_CMD_ABSPOINTER_RESTRICT 86 +#define VMWARE_CMD_ABSPOINTER_DATA 39 +#define VMWARE_CMD_ABSPOINTER_STATUS 40 +#define VMWARE_CMD_ABSPOINTER_COMMAND 41 +#define VMWARE_CMD_ABSPOINTER_RESTRICT 86 /* - * Subcommands for VMMOUSE_PROTO_CMD_ABSPOINTER_COMMAND + * Subcommands for VMWARE_CMD_ABSPOINTER_COMMAND */ #define VMMOUSE_CMD_ENABLE 0x45414552U #define VMMOUSE_CMD_DISABLE 0x000000f5U @@ -76,28 +73,6 @@ struct vmmouse_data { char dev_name[128]; }; -/* - * Hypervisor-specific bi-directional communication channel - * implementing the vmmouse protocol. Should never execute on - * bare metal hardware. - */ -#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4) \ -({ \ - unsigned long __dummy1, __dummy2; \ - __asm__ __volatile__ (VMWARE_HYPERCALL : \ - "=a"(out1), \ - "=b"(out2), \ - "=c"(out3), \ - "=d"(out4), \ - "=S"(__dummy1), \ - "=D"(__dummy2) : \ - "a"(VMMOUSE_PROTO_MAGIC), \ - "b"(in1), \ - "c"(VMMOUSE_PROTO_CMD_##cmd), \ - "d"(0) : \ - "memory"); \ -}) - /** * vmmouse_report_button - report button state on the correct input device * @@ -145,14 +120,12 @@ static psmouse_ret_t vmmouse_report_events(struct psmouse *psmouse) struct input_dev *abs_dev = priv->abs_dev; struct input_dev *pref_dev; u32 status, x, y, z; - u32 dummy1, dummy2, dummy3; unsigned int queue_length; unsigned int count = 255; while (count--) { /* See if we have motion data. */ - VMMOUSE_CMD(ABSPOINTER_STATUS, 0, - status, dummy1, dummy2, dummy3); + status = vmware_hypercall1(VMWARE_CMD_ABSPOINTER_STATUS, 0); if ((status & VMMOUSE_ERROR) == VMMOUSE_ERROR) { psmouse_err(psmouse, "failed to fetch status data\n"); /* @@ -172,7 +145,8 @@ static psmouse_ret_t vmmouse_report_events(struct psmouse *psmouse) } /* Now get it */ - VMMOUSE_CMD(ABSPOINTER_DATA, 4, status, x, y, z); + status = vmware_hypercall4(VMWARE_CMD_ABSPOINTER_DATA, 4, + &x, &y, &z); /* * And report what we've got. Prefer to report button @@ -247,14 +221,10 @@ static psmouse_ret_t vmmouse_process_byte(struct psmouse *psmouse) static void vmmouse_disable(struct psmouse *psmouse) { u32 status; - u32 dummy1, dummy2, dummy3, dummy4; - - VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_DISABLE, - dummy1, dummy2, dummy3, dummy4); - VMMOUSE_CMD(ABSPOINTER_STATUS, 0, - status, dummy1, dummy2, dummy3); + vmware_hypercall1(VMWARE_CMD_ABSPOINTER_COMMAND, VMMOUSE_CMD_DISABLE); + status = vmware_hypercall1(VMWARE_CMD_ABSPOINTER_STATUS, 0); if ((status & VMMOUSE_ERROR) != VMMOUSE_ERROR) psmouse_warn(psmouse, "failed to disable vmmouse device\n"); } @@ -271,26 +241,24 @@ static void vmmouse_disable(struct psmouse *psmouse) static int vmmouse_enable(struct psmouse *psmouse) { u32 status, version; - u32 dummy1, dummy2, dummy3, dummy4; /* * Try enabling the device. If successful, we should be able to * read valid version ID back from it. */ - VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_ENABLE, - dummy1, dummy2, dummy3, dummy4); + vmware_hypercall1(VMWARE_CMD_ABSPOINTER_COMMAND, VMMOUSE_CMD_ENABLE); /* * See if version ID can be retrieved. */ - VMMOUSE_CMD(ABSPOINTER_STATUS, 0, status, dummy1, dummy2, dummy3); + status = vmware_hypercall1(VMWARE_CMD_ABSPOINTER_STATUS, 0); if ((status & 0x0000ffff) == 0) { psmouse_dbg(psmouse, "empty flags - assuming no device\n"); return -ENXIO; } - VMMOUSE_CMD(ABSPOINTER_DATA, 1 /* single item */, - version, dummy1, dummy2, dummy3); + version = vmware_hypercall1(VMWARE_CMD_ABSPOINTER_DATA, + 1 /* single item */); if (version != VMMOUSE_VERSION_ID) { psmouse_dbg(psmouse, "Unexpected version value: %u vs %u\n", (unsigned) version, VMMOUSE_VERSION_ID); @@ -301,11 +269,11 @@ static int vmmouse_enable(struct psmouse *psmouse) /* * Restrict ioport access, if possible. */ - VMMOUSE_CMD(ABSPOINTER_RESTRICT, VMMOUSE_RESTRICT_CPL0, - dummy1, dummy2, dummy3, dummy4); + vmware_hypercall1(VMWARE_CMD_ABSPOINTER_RESTRICT, + VMMOUSE_RESTRICT_CPL0); - VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_REQUEST_ABSOLUTE, - dummy1, dummy2, dummy3, dummy4); + vmware_hypercall1(VMWARE_CMD_ABSPOINTER_COMMAND, + VMMOUSE_CMD_REQUEST_ABSOLUTE); return 0; } @@ -342,7 +310,7 @@ static bool vmmouse_check_hypervisor(void) */ int vmmouse_detect(struct psmouse *psmouse, bool set_properties) { - u32 response, version, dummy1, dummy2; + u32 response, version, type; if (!vmmouse_check_hypervisor()) { psmouse_dbg(psmouse, @@ -351,9 +319,9 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties) } /* Check if the device is present */ - response = ~VMMOUSE_PROTO_MAGIC; - VMMOUSE_CMD(GETVERSION, 0, version, response, dummy1, dummy2); - if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU) + response = ~VMWARE_HYPERVISOR_MAGIC; + version = vmware_hypercall3(VMWARE_CMD_GETVERSION, 0, &response, &type); + if (response != VMWARE_HYPERVISOR_MAGIC || version == 0xffffffffU) return -ENXIO; if (set_properties) {