From nobody Mon May 6 13:33:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593634197; cv=none; d=zohomail.com; s=zohoarc; b=fMvtw49l/mKNexb+whIUrxvz29BpzdeqlDgHu2scw8DVYq5tqF2eOOdPnFMwhqfkt45Csne89+aXIZYoIMcT6+kanfK9BnqIqUT3fYJ+M/AhtyL44o76npgV+I8OOOB7cTfKhqcpveAbvlvNTCMEgaKrjZL9dVMCdVgRwtLYkbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593634197; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=87Bd2G7JErAV7VuB/zp118TFFyq0xCmS/os9wVhf8qc=; b=S32FJT900xvVBw3lAYyeHPLYhro8LNng59sWl6IJMMWW5OyJeYG/KO4SVAmaO5bZlY7jGCETdU0r2PIIiknH88IahDKp9VhQuDoHnKMx5Cifjml8l5YoQtqMY23Zwwdi2c0x0wNBcdd1PAnaX6kmG9+kZCtFpXn2IVaOyerelx0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593634197494359.7833669893382; Wed, 1 Jul 2020 13:09:57 -0700 (PDT) Received: from localhost ([::1]:35772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqj3L-0007jy-KD for importer@patchew.org; Wed, 01 Jul 2020 16:09:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqj2M-0006zq-PD; Wed, 01 Jul 2020 16:08:54 -0400 Received: from mail.csgraf.de ([188.138.100.120]:40968 helo=zulu616.server4you.de) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqj2K-0002sY-Ml; Wed, 01 Jul 2020 16:08:54 -0400 Received: from server.alex.local (x4d024519.dyn.telefonica.de [77.2.69.25]) by csgraf.de (Postfix) with ESMTPSA id A80B339002CE; Wed, 1 Jul 2020 22:08:49 +0200 (CEST) From: Alexander Graf To: qemu-devel@nongnu.org Subject: [PATCH] target/arm: Treat unknown SMC calls as NOP Date: Wed, 1 Jul 2020 22:08:48 +0200 Message-Id: <20200701200848.26746-1-agraf@csgraf.de> X-Mailer: git-send-email 2.16.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=188.138.100.120; envelope-from=agraf@csgraf.de; helo=zulu616.server4you.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/01 15:51:46 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We currently treat unknown SMC calls as UNDEF. This behavior is different from KVM, which treats them as NOP. Unfortunately, the UNDEF exception breaks running Windows for ARM in QEMU, as that probes an OEM SMCCC call on boot, but does not expect to receive an UNDEF exception as response. So instead, let's follow the KVM path and ignore SMC calls that we don't handle. This fixes booting the Windows 10 for ARM preview in TCG for me. Signed-off-by: Alexander Graf --- target/arm/helper.c | 8 ++++++++ target/arm/op_helper.c | 13 ++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index dc9c29f998..bc1bd2e704 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9778,6 +9778,14 @@ void arm_cpu_do_interrupt(CPUState *cs) return; } =20 + if (cs->exception_index =3D=3D EXCP_SMC && + !arm_feature(env, ARM_FEATURE_EL3) && + cpu->psci_conduit !=3D QEMU_PSCI_CONDUIT_SMC) { + /* Treat unknown SMC calls as NOP, just like KVM */ + qemu_log_mask(CPU_LOG_INT, "...handled as NOP\n"); + return; + } + /* * Semihosting semantics depend on the register width of the code * that caused the exception, not the target exception level, so diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index b1065216b2..42b1687860 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -823,7 +823,7 @@ void HELPER(pre_smc)(CPUARMState *env, uint32_t syndrom= e) * * Conduit SMC, valid call Trap to EL2 PSCI Call * Conduit SMC, inval call Trap to EL2 Undef insn - * Conduit not SMC Undef insn Undef insn + * Conduit not SMC nop nop */ =20 /* On ARMv8 with EL3 AArch64, SMD applies to both S and NS state. @@ -838,16 +838,11 @@ void HELPER(pre_smc)(CPUARMState *env, uint32_t syndr= ome) =20 if (!arm_feature(env, ARM_FEATURE_EL3) && cpu->psci_conduit !=3D QEMU_PSCI_CONDUIT_SMC) { - /* If we have no EL3 then SMC always UNDEFs and can't be - * trapped to EL2. PSCI-via-SMC is a sort of ersatz EL3 - * firmware within QEMU, and we want an EL2 guest to be able - * to forbid its EL1 from making PSCI calls into QEMU's - * "firmware" via HCR.TSC, so for these purposes treat - * PSCI-via-SMC as implying an EL3. + /* If we have no EL3 then we simulate KVM behavior which + * simply treats every unknown SMC as a nop. * This handles the very last line of the previous table. */ - raise_exception(env, EXCP_UDEF, syn_uncategorized(), - exception_target_el(env)); + return; } =20 if (cur_el =3D=3D 1 && (arm_hcr_el2_eff(env) & HCR_TSC)) { --=20 2.16.4