From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D334C63697 for ; Wed, 4 Nov 2020 18:37:15 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 9EFEA20BED for ; Wed, 4 Nov 2020 18:37:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="RUE++rKQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EFEA20BED Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 404B54B7B7; Wed, 4 Nov 2020 13:37:14 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kSDe17TcgWxJ; Wed, 4 Nov 2020 13:37:13 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BED144B7BE; Wed, 4 Nov 2020 13:37:11 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 89E6B4B6D6 for ; Wed, 4 Nov 2020 13:37:10 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UaWL9dHKWb8E for ; Wed, 4 Nov 2020 13:37:09 -0500 (EST) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 5F95E4B6A3 for ; Wed, 4 Nov 2020 13:37:09 -0500 (EST) Received: by mail-wm1-f67.google.com with SMTP id c9so3346347wml.5 for ; Wed, 04 Nov 2020 10:37:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9j0VMjjA6zCDdyx35vluqon5elvOXnResZEBXNSr1X0=; b=RUE++rKQXhZNCONaCTR19/HxXtVIIi3oRNevbUdThFpb7lSGOWgZt53CvjYIojGFXp bjoAX5PN9KRdcmvSZhoOooosMjRsjhO3yOCLuFsmXBnGqzHK6fNjiqbiboERhaoR7c65 AMmH+DGH/eYH/7R0jg5d77ub+nd4XbwPgg1O4y2VRz3/Jr8HAi516eAnsOUKhoFimz+U Rygz++/YusK5YxpHxDmVPdIlb5tTRErFbiYlp8wV57FtQTu49uSxeIyuOdoBt1iNhtHe b+NAvqUVRGyEdVlL/l8GZB8iHlSVM8gpAPm9CXxsZbVe2yoe6fVtsZ6ddqmVgU3IIcVq w77A== 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:mime-version:content-transfer-encoding; bh=9j0VMjjA6zCDdyx35vluqon5elvOXnResZEBXNSr1X0=; b=fBijqJHnN/C6XbWWQHXYAZbzkntYwAaHQI4RFfAJzTYxX6eY5nQNJuoFeu+WQTUy6J rQkSryWEFsHADxluM6v9Ng1lF65XaP5TSCZhwh77mkThgB0zWD9QjJHDruewUOvcliht 9zZvKdLiyL12xeQN93TRqGEVNV0nNSzp9Aw2HKb2bHGi7DA+H6WE6Z1Lo7xJBdhoXNVa E0c4Pkb5VsyafVg+kvRVvBudYHbTIngSA3PqLBlfezJmYyxbjFLINfyMlw37EKtFC5nN gtpq7r3xZ9MzO9h8vb1xnoyYhztAQLe5GitzVmRpWDDcnYjpYd0d/Hw3ZWlZhx+tn6ea HhkQ== X-Gm-Message-State: AOAM530thfhoOYNNc3Rwk0rYvWjcNG+1ivW69kQyc1+4mj3eE5kGfAzM 56fHBR10SnCcyvSm1J9bSD5qqpelAnvG29gc X-Google-Smtp-Source: ABdhPJzlA4HqRs854B2x+X/0kGzJzOL2QkOaSVtVknIKK6zQbS8XLXIwWdn8f9VXnZzMY6cgY+W9ng== X-Received: by 2002:a7b:c748:: with SMTP id w8mr6056505wmk.32.1604515028016; Wed, 04 Nov 2020 10:37:08 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:c8d2:30f2:53c6:bc2]) by smtp.gmail.com with ESMTPSA id 90sm3934768wrl.30.2020.11.04.10.37.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 10:37:06 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [RFC PATCH 14/26] kvm: arm64: Forward safe PSCI SMCs coming from host Date: Wed, 4 Nov 2020 18:36:18 +0000 Message-Id: <20201104183630.27513-15-dbrazdil@google.com> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104183630.27513-1-dbrazdil@google.com> References: <20201104183630.27513-1-dbrazdil@google.com> MIME-Version: 1.0 Cc: Lorenzo Pieralisi , kernel-team@android.com, Marc Zyngier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Tejun Heo , Dennis Zhou , Christoph Lameter , Will Deacon X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Forward the following PSCI SMCs issued by host to EL3 as they do not require the hypervisor's intervention. This assumes that EL3 correctly implements the PSCI specification. Only function IDs implemented in Linux are included. Where both 32-bit and 64-bit variants exist, it is assumed that the host will always use the 64-bit variant. * SMCs that only return information about the system * PSCI_VERSION - PSCI version implemented by EL3 * PSCI_FEATURES - optional features supported by EL3 * AFFINITY_INFO - power state of core/cluster * MIGRATE_INFO_TYPE - whether Trusted OS can be migrated * MIGRATE_INFO_UP_CPU - resident core of Trusted OS * operations which do not affect the hypervisor * MIGRATE - migrate Trusted OS to a different core * SET_SUSPEND_MODE - toggle OS-initiated mode * system shutdown/reset * SYSTEM_OFF * SYSTEM_RESET * SYSTEM_RESET2 Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/psci.c | 40 +++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/psci.c b/arch/arm64/kvm/hyp/nvhe/psci.c index 82d3b2c89658..8f779560ab6f 100644 --- a/arch/arm64/kvm/hyp/nvhe/psci.c +++ b/arch/arm64/kvm/hyp/nvhe/psci.c @@ -50,14 +50,48 @@ static bool is_psci_call(u64 func_id) return is_psci_0_2_fn_call(func_id); } +static unsigned long psci_call(unsigned long fn, unsigned long arg0, + unsigned long arg1, unsigned long arg2) +{ + struct arm_smccc_res res; + + arm_smccc_1_1_smc(fn, arg0, arg1, arg2, &res); + return res.a0; +} + +static unsigned long psci_forward(struct kvm_cpu_context *host_ctxt) +{ + return psci_call(host_ctxt->regs.regs[0], host_ctxt->regs.regs[1], + host_ctxt->regs.regs[2], host_ctxt->regs.regs[3]); +} + +static __noreturn unsigned long psci_forward_noreturn(struct kvm_cpu_context *host_ctxt) +{ + psci_forward(host_ctxt); + hyp_panic(); /* unreachable */ +} + static unsigned long psci_0_1_handler(u64 func_id, struct kvm_cpu_context *host_ctxt) { - return PSCI_RET_NOT_SUPPORTED; + if (func_id == kvm_host_psci_function_id[PSCI_FN_MIGRATE]) + return psci_forward(host_ctxt); + else + return PSCI_RET_NOT_SUPPORTED; } static unsigned long psci_0_2_handler(u64 func_id, struct kvm_cpu_context *host_ctxt) { switch (func_id) { + case PSCI_0_2_FN_PSCI_VERSION: + case PSCI_0_2_FN64_AFFINITY_INFO: + case PSCI_0_2_FN64_MIGRATE: + case PSCI_0_2_FN_MIGRATE_INFO_TYPE: + case PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU: + return psci_forward(host_ctxt); + case PSCI_0_2_FN_SYSTEM_OFF: + case PSCI_0_2_FN_SYSTEM_RESET: + psci_forward_noreturn(host_ctxt); + unreachable(); default: return PSCI_RET_NOT_SUPPORTED; } @@ -72,6 +106,10 @@ static unsigned long psci_1_0_handler(u64 func_id, struct kvm_cpu_context *host_ return ret; switch (func_id) { + case PSCI_1_0_FN_PSCI_FEATURES: + case PSCI_1_0_FN_SET_SUSPEND_MODE: + case PSCI_1_1_FN64_SYSTEM_RESET2: + return psci_forward(host_ctxt); default: return PSCI_RET_NOT_SUPPORTED; } -- 2.29.1.341.ge80a0c044ae-goog _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm