From patchwork Mon Oct 15 15:32:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 148864 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3933943lji; Mon, 15 Oct 2018 08:32:36 -0700 (PDT) X-Received: by 2002:ac8:23ad:: with SMTP id q42-v6mr16777582qtq.322.1539617556519; Mon, 15 Oct 2018 08:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539617556; cv=none; d=google.com; s=arc-20160816; b=zGZZ6P6VRn6d4imHsdnS0eJ12FPuvPxl4wQk5SSpniIkLLFty0tzg0RRvkkLOFeoqf JhX5bfZ6Kihn2Q6Pi5qHGyJzq91appJOGWBOZnbHGV2559WdsVPokuU+rczSFZCtph+7 gy+UtyCM3Oc7AR1pLQuu2YGCntp2gMKFZ9fm3ikTfa3j0pNAkNUNVqYbmzJNkej7boMQ Cd4/uqx+8PdIYU4eEhA3LQdeyGugJyMDMA79UINXw0NDBdWlY+ckZPt+fKIyoC3GLRsz v4O6zFkN9LNVWrvxHlU00LkT49lHM9fX/SJCbwqEaMb4dSIb1aXYGhHwdRPsJNeSPY8K OeUw== 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=l0F/4WOicKz2bJZ4mYYrCaB4xT07LccxO7VX90vuudg=; b=dQc3YGIT3sdR/kasviJlRFx4LmBjkt5hBzNp5KqJIJuMLr6oW/UGZi6QZH5llrJnjW LcEMH4T+uSFB9JvnubnMcPD+5rdHF+pgl7+aU1pHEeHRkBBLo8EJUwtwF3Ap9kMuI87w qVzzjeHbJvsEDhmdyPqfRYslid/HfItZHh5jgR7PLkUBgmSNvJfYtNfYy0CD7DB0HMrr 28FE8GD0LstMYPJzQ40DZtmAwl1zzP1qt43zK9ahoGSKcJV87BdB9+sdMVqw3kEWSWCb NzBEd2K/VxloOhEJ7YqZuezkNv1I5IpeTgc+KlWOzqNqeVIstrUIJjfbPkytGsLUiwFQ wFTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C6QEMfax; 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 m21-v6sor12611875qtb.3.2018.10.15.08.32.36 for (Google Transport Security); Mon, 15 Oct 2018 08:32:36 -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=C6QEMfax; 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=l0F/4WOicKz2bJZ4mYYrCaB4xT07LccxO7VX90vuudg=; b=C6QEMfaxHfS8luBNlJ18N5G7mZ9/N2cvDxwqdl6X3Mm15h2VrR5V5GwNvN0frlhLha HKbmEqDdRryT+FetdiJGkc4+wCFxMm+mGzlGZBROYTTZuo9uEUuDbuOhKeHcTt9ttRUL suzjBjib3VVQpfytzr3nJYoEaKGTfC4hT33KM= 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=l0F/4WOicKz2bJZ4mYYrCaB4xT07LccxO7VX90vuudg=; b=Josl/CjsqAkY3LZF5MeNVJJmXaTgj5YZCRCtGqDsr/mRRkRKX26BDY1TyncKV1lmRv o7zf5DCV4MqEN2+FnI3E9lunDE3lOhx7OEzNHc+BATsfhM3UUowROwyxT2EgiibJwRTz jbKJiw1CvH/kT+NcqSTSj25FeUJo0t7W7KqoR4xzZMN7wDjq+vjlDT8zYY/jjwdSkzyB SNGNZEcynhGm2fJj2MFX3a7GJCTJxjfrQO83tN6dtlPdLd1kUiSn4tg582jITTyG7FSn 1xh3Xg29DYXABPQ0AHY8Y0UqHaveTgmSgTvx07g2F3cOU3lapW+yjziYQ2ixEuRsk5/C 9QSw== X-Gm-Message-State: ABuFfoij57EmUfEgwHPYdUo6/7uXft2mgNmmAKk/Esq3U5UM1Tdl6suE Lc4OPBGunsWemHiSBLAgAILEy3Yb X-Google-Smtp-Source: ACcGV60m73tTgBMWb2qJMFUG865pB5TM1Bajc+494tyzwo8QTj8nhxbrSATEZ3qhhOYmJzYCq8XQvQ== X-Received: by 2002:ac8:3026:: with SMTP id f35-v6mr16329706qte.45.1539617556117; Mon, 15 Oct 2018 08:32:36 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([72.71.243.63]) by smtp.googlemail.com with ESMTPSA id g82-v6sm10087768qkh.24.2018.10.15.08.32.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Oct 2018 08:32:35 -0700 (PDT) From: David Long To: , Russell King - ARM Linux , Florian Fainelli , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 14/24] ARM: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling Date: Mon, 15 Oct 2018 11:32:08 -0400 Message-Id: <1539617538-22328-15-git-send-email-dave.long@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1539617538-22328-1-git-send-email-dave.long@linaro.org> References: <1539617538-22328-1-git-send-email-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.5.0 diff --git a/arch/arm/kvm/hyp/hyp-entry.S b/arch/arm/kvm/hyp/hyp-entry.S index 918a05d..aa3f9a9 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 @@ -253,6 +254,20 @@ THUMB( orr lr, #1) pop {r2, lr} 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