From patchwork Wed Nov 7 16:43:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 150429 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5387412ljp; Wed, 7 Nov 2018 08:44:22 -0800 (PST) X-Received: by 2002:a37:7041:: with SMTP id l62-v6mr887468qkc.294.1541609062290; Wed, 07 Nov 2018 08:44:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541609062; cv=none; d=google.com; s=arc-20160816; b=mJNWNPD9dk6g/FBmriO4U0VnWvau1z1lu9HMZoaz9Ikp61S+If0GQwMnX6eKHeDYU6 7QZ3JXMhu73zD21jUBXcvXlLxtUWb7A1A+8ODuR+xdt0Mx4Pu3Lvhg8kg8pDKTkGK6vr RR825Tz4TyOXPHPtrSCT1rF3Aaue4EridOgG0s2C3BUOztY/HQ4PWUeaKIdcEt8hPH55 h7Rpfr4umfBspZL6Io7lvzNylCp7xbDiNii3du4SKmGeWnBgcVk/9gAxdyGymusKKVW/ BH7G53kp03Sh/1ufbs0/kf1e05Zo23WQ2mTMnvM5kzeVmRKE3DZx2ZK6ZfeKCI7bvcdi 9Oag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8WVSH+dweMgRGD7h+AhioIATdNkgmA/7ASgHKYf1OcU=; b=yzAJBibY+R5bUdVTqBpjKrMcbG3SrVp6M/GLmWH+7gTC9M70Vc1pOSzS+YpNsm0a91 deecRWgPUq/i6i1l1Z1kVrpAccBO0MAInZ/o7+hmuV3+2p2srjl1c9i8dSeOO/SXdDbp TrpMZkpyfmHphfOQBsyw3uhzuVfjorlvYC0UrPLXtv0MjeCUNuFd6JGvZzvYBvV2eYol Tgmwl138s6+Rqx/Fu+a5no667nm48OZIISuoV+gBoUGjGmNeNTb3QJdyqTZi619QVTPn 7/z5nFRd/p9OKseECA7v9puAaAGq4vmYyGgG/N4JCpOLGNIFtC13OlSoRs0ugpPb+ZcG QYsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="J6jCxUY/"; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id l67sor652691qke.81.2018.11.07.08.44.22 for (Google Transport Security); Wed, 07 Nov 2018 08:44:22 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="J6jCxUY/"; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8WVSH+dweMgRGD7h+AhioIATdNkgmA/7ASgHKYf1OcU=; b=J6jCxUY/1KiXlfD+n+QoZil9rGaoTsipLclj0hJ2kl87/bObA6pQgTTeYhgwf8OUUp khacvx0dAN28eI6oSTkhdiGDCqbF3YtdjszS/oBPde+rGli0/Hk2PR2NhUzMc/XZUE0Y C33Edo+TfOuaW+6tu/zdrof4guiM6xfO0UyBE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8WVSH+dweMgRGD7h+AhioIATdNkgmA/7ASgHKYf1OcU=; b=FPFB6HdVTLqFmeszeTISZZunf+o8khoJNAUMK30CiA7Cvw2JcQAnUdIvtr9I7p0OND AOUl0OgRFJENOXioGyst5p7wouBpa8xbg9t5vdMTQxeElYzK/M3TSj5jNq0LHaYb0oHR O137kIlndpFaJFGwiT4RPCubnNXPfYxjeBsSpWs2DslMF2TuRkseN50lnqAlno/mjGFw kTHvZR/xGGESMyWVu8HoyX/iVvCWQBQ8eDEDMSQqWbiWELk0wNtF3cov10Fu9KsavMDS p16RHB+HtZuj10OhiHzieAawyMQX6Bftcb9iOdG8cF9zaRnVNgiNFbkYH3yxWZidZZAK sEpw== X-Gm-Message-State: AGRZ1gKE1PrxPxXSdOGAeZbpeg9DQ3scGUVJ9hWcBalAv5wIz7yhbnp7 pO9iWXt2atSiUVoQaapWtBA8w72V X-Google-Smtp-Source: AJdET5cAg+aOv5gvBi4XSRJjteeMxhT23FndpWkp1DF2OnyJlJl2e127hzmuCofl9ZlxF9ZeaEVHSA== X-Received: by 2002:a37:12a1:: with SMTP id 33mr899759qks.151.1541609061753; Wed, 07 Nov 2018 08:44:21 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 96-v6sm681817qtc.56.2018.11.07.08.44.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 08:44:21 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.9 V2 14/24] ARM: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling Date: Wed, 7 Nov 2018 11:43:52 -0500 Message-Id: <20181107164402.9380-15-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181107164402.9380-1-dave.long@linaro.org> References: <20181107164402.9380-1-dave.long@linaro.org> From: Russell King Commit b800acfc70d9fb81fbd6df70f2cf5e20f70023d0 upstream. We want SMCCC_ARCH_WORKAROUND_1 to be fast. As fast as possible. So let's intercept it as early as we can by testing for the function call number as soon as we've identified a HVC call coming from the guest. Signed-off-by: Russell King Boot-tested-by: Tony Lindgren Reviewed-by: Tony Lindgren Reviewed-by: Marc Zyngier Signed-off-by: David A. Long --- arch/arm/kvm/hyp/hyp-entry.S | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/arch/arm/kvm/hyp/hyp-entry.S b/arch/arm/kvm/hyp/hyp-entry.S index 1bdd03014138..64d4a39f4b4b 100644 --- a/arch/arm/kvm/hyp/hyp-entry.S +++ b/arch/arm/kvm/hyp/hyp-entry.S @@ -16,6 +16,7 @@ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -202,7 +203,7 @@ hyp_hvc: lsr r2, r2, #16 and r2, r2, #0xff cmp r2, #0 - bne guest_trap @ Guest called HVC + bne guest_hvc_trap @ Guest called HVC /* * Getting here means host called HVC, we shift parameters and branch @@ -235,6 +236,20 @@ THUMB( orr lr, #1) pop {r2, lr} 1: eret +guest_hvc_trap: + movw r2, #:lower16:ARM_SMCCC_ARCH_WORKAROUND_1 + movt r2, #:upper16:ARM_SMCCC_ARCH_WORKAROUND_1 + ldr r0, [sp] @ Guest's r0 + teq r0, r2 + bne guest_trap + add sp, sp, #12 + @ Returns: + @ r0 = 0 + @ r1 = HSR value (perfectly predictable) + @ r2 = ARM_SMCCC_ARCH_WORKAROUND_1 + mov r0, #0 + eret + guest_trap: load_vcpu r0 @ Load VCPU pointer to r0