From patchwork Wed Oct 31 13:57:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 149808 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6826630ljp; Wed, 31 Oct 2018 06:57:35 -0700 (PDT) X-Received: by 2002:ab0:43c1:: with SMTP id l59mr1433169ual.93.1540994255172; Wed, 31 Oct 2018 06:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540994255; cv=none; d=google.com; s=arc-20160816; b=fByQyppfCZ0rFHoTfmpV3kUjzaNzUULiIFTpzaCpp+yY8ulyroaVj6XvkfIAUvFUab fhNIU4RrOTNKaIfTMq+w7iWL9KygW3PAJv3B3qvInkvmImiWMhzIpAjWciwHwvnWdPFf QTJtnUs5VgrrDbmR7+kI7BsXMJBvyFDr1QSts0FunQOlLnQzukUY8rlMQCOMvRDmVxxG BcPeWoZHtcMbdHzN37Ga1hxBXEqVHT0Jm9tqGJVcmp/7rcR4AvxhPZAIWbsJ7LINYSUv 8NyEyp5eOwXyMPlGWCkjXY1B1F/eHtcoZVjGN49irTGU7C0u09uGAeO4wLt//eq0RL98 lpFg== 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=bNXye7qSHBcxKzkcW+g1SswXnwzA9q0ZEHRc9gs5Nys=; b=Lg77QCl96Lc6EnX4asQhVc6aMd/vZ+L3ZRLjL5CGfIRgPmwvebDBZSQkC8rSE5xlaN GVmH7Ts6Z3zqLBSeCSPvjD1avFcWiKvj/SVLZO8HNmktbWnqtCWYcfJqL8flDt59qLx8 JXJLz3d/mFnACd8l4Km19Wy6Nb4cios+T9OE7WoIqn+c9e1kV/QzhsFqWEST/WM8zQgk MdY/YmpewJepxhoTIMbfSLdozhBgL4VA++a+RJ7IOYcqMGe+YvwB9ShM5QUtcttsRRaq FFOrMb632d8XJJHrxITb3u8fDdKxKjMVKSfP8mt3vjIXPcnY1nO0VNqfweDkeiR0EDGj dVYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tgzl1Nk4; 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 a34sor16215251uae.38.2018.10.31.06.57.35 for (Google Transport Security); Wed, 31 Oct 2018 06:57:35 -0700 (PDT) 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=Tgzl1Nk4; 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=bNXye7qSHBcxKzkcW+g1SswXnwzA9q0ZEHRc9gs5Nys=; b=Tgzl1Nk40RmOTUx5ozu1MpnJqHH0iFyM7RxpoKpKI5zXWIbhe69XR8OVILEf3VmF7G cKCWzUqIY+nNFgoezuhdNwmk4Xo9h+Z7tKzWcP1aQq1pChpKqfqnpTr48xxHrwXk9k0U ZYBw5SoaldZtgd5YZCAuL1XxCKOAM4TU/yVmQ= 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=bNXye7qSHBcxKzkcW+g1SswXnwzA9q0ZEHRc9gs5Nys=; b=OD2bmguQ3Mfw8/GVBJLtOgh4iRHWJUh/VkrER0otsmFmVBK1SoXBjO9V+zQiCg6QvC mOqkTz0zQ3GCUsiMRKGnGq7X1DDbXZ8jA5RDX0MuKJDM8ZA4KB9fxA4do4L11wa/0o2V PyvfG27DtygWR6NxVUAzWHQqRoYXmjhYDE9sXRVze2vsDKIerZ050gXLaOOdyHpzVNqG gJcufOhlfZR8kCKF3aw29CpAwftFlpbryb388tmwfiUt6kLMOBalKKr3AzGma/nRc0dN qcf4p3Dy1s5qLxopHS4j9bUlBGadABcxlzeKWcvngj77MZwTfIZaaIJYuBlA4NMZYmzA 4QMg== X-Gm-Message-State: AGRZ1gLVEzCt9Hm5LSIeujw88RaRBRMslbYGRuY/zZjisteuSw+cOAyD vrDI3s71TDRfs/yzM/Td1Om7KO+3 X-Google-Smtp-Source: AJdET5ePX44Iw02JBlth2K6YiAbVvZu/8UqyCJvepCJ4fIQIC/WZqoCLAv3D18m7xOuwErp1HSu4dw== X-Received: by 2002:a9f:3526:: with SMTP id o35mr1356074uao.70.1540994254671; Wed, 31 Oct 2018 06:57:34 -0700 (PDT) Return-Path: Received: from dave-Dell-System-XPS-L502X.hsd1.nh.comcast.net ([2603:3005:3403:7100:2c71:8680:34e1:a6aa]) by smtp.googlemail.com with ESMTPSA id s85-v6sm2275624vse.29.2018.10.31.06.57.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 06:57:33 -0700 (PDT) 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 14/24] ARM: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling Date: Wed, 31 Oct 2018 09:57:03 -0400 Message-Id: <20181031135713.2873-15-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031135713.2873-1-dave.long@linaro.org> References: <20181031135713.2873-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 582f50759d80..a3c81bb7ce8b 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 @@ -237,6 +238,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