From patchwork Tue Mar 9 14:17:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 395994 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2622392jai; Tue, 9 Mar 2021 06:18:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwioRd7MVkUD9MLBOYbu7LVkYp6FoZQNUyNtQFLiJCfGK5xSjr1f20/xU/AQ2qhjxraz0lg X-Received: by 2002:a05:6602:80d:: with SMTP id z13mr22291779iow.17.1615299486525; Tue, 09 Mar 2021 06:18:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615299486; cv=none; d=google.com; s=arc-20160816; b=dmo0z7rR+NR64C12ldL2oHsX7P2IjGaFQ1kAlJtvxqT2Iypyyxg6tHmsP5j+9n+eEQ xhWf3JeI63KwQGtA2flVR8fRDXqNmyJ900u5tniSpfVInwGSnVfsHrmjGb7h/FbVPNfo 5xPCrgaPz1x3W8ETLIlI5k6Py9bHd+l41f9ktQaciq+G1Ymyff27NLFkEDKUBKDbtbJF BXf9RNJQ4DdE0WOVIxfTxTmwaRqATJ3q1Lk8mMTkrBdt8f8FN4+++YVyVhP/iOGkPyJ0 AMGe1I9UyXpHXpHgib8govTo6oHy5e4gAhClucz3GQxkCRXWPw+1DCb0HPWaVYdEnAx1 894A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=pOpDSl4PCJAfRmZAM02jJCUO0bme5ak2R8cL4PaIcKc=; b=LLW5meQPGgmLXJTYm6sQ1ipBqL66N/zrkRniS5xFDfUTtFDwu709mhjRDJPR3z22PN 9iBc4MQw9115jHAOj0XwCJsgc8OaUWl2mhiMdarCqhDvYUOC/TvLMmxSweG37iPaaC93 5HvDVrakZB//QNm3ZmBJrokDGcCnrhJqFEJkOQ4eYbXI2fmTYkNF7w2s8JoWCXoVN/Nv FcU58p6AqGyCwwv06PVB0OPotNhCBJ430oRWP4KReFAYt+eAAilnnePX9UOPQblRwYSE GADKff/nXPP582dOTKf0VlUXj0ej7mvfKTKmbGwNW38V6HZA8svWzYKMbW2CJ2vR0rfE lDCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iqK218Cj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u9si14511395ilb.141.2021.03.09.06.18.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Mar 2021 06:18:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iqK218Cj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJdBV-0001P9-TM for patch@linaro.org; Tue, 09 Mar 2021 09:18:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJdB0-0001Id-52 for qemu-devel@nongnu.org; Tue, 09 Mar 2021 09:17:34 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:41160) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJdAx-0001go-V6 for qemu-devel@nongnu.org; Tue, 09 Mar 2021 09:17:33 -0500 Received: by mail-wr1-x429.google.com with SMTP id f12so15906126wrx.8 for ; Tue, 09 Mar 2021 06:17:31 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=pOpDSl4PCJAfRmZAM02jJCUO0bme5ak2R8cL4PaIcKc=; b=iqK218CjKd3kHxPFcwXkPIoIpsAOO610z0RIy9AIZypbibOIh5GRIi3o53mh9nYA1A ldFOr1aX8AVhd4zVd13oQl3Nt0wzCF/4609qmKcd6BWZ2i1NvrP90NkxLYUSkG5NgNhx mWVVg6Ik5YLxXuz+O7PE+k4FMMKkW9Tmm6hzY9ZOIDUyatNmUz6igi+qD8VmW4QNtfwF iu5Lakbm1qFK2akwDQyLhw/5wlun9DsykM3hhi0m0tfMyrQh4LnCb2aSSGVBB5JzmuAc FXJXRptNRREvAh/uuOX/SnnARm+96fr3FXeYDAcL+OeJUnj5GWDx4cx//ojunq6SVGJc P/bA== 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=pOpDSl4PCJAfRmZAM02jJCUO0bme5ak2R8cL4PaIcKc=; b=LIduNSbyEES9mplQm+XrKgdvmtkK4Cad9rdE453yrr6kcPyzVPcwaquVYnucE5JuVL qzAP3UuqUsjRUB4tUTk8bS7VOHWKWZCY6tXgJpS2OcIZWjHBmGcwCgsmFjTNWI/0dPbY ITxy1rZu3TGx8QxkPr7mFi/fC5+27Soyt/YtRLDLjj9Z9ZcXfjfRhrUZJlQ2K0J9h9Q0 bpdCFDcbnuQARrXquFmwdnihr33DmsAtlt1W8vq0uNE0xfsRMiFfvUv5+HCq1nl4a/bc GO1O3V7SUZEQ4uqhAnDJNnOXqsbsnBHTN/eSpK8IQIcX1cZSetsQE+2UGMNiKu7aFTYd pMkg== X-Gm-Message-State: AOAM532BR3zTKV9dEnlM0arZ/qFxIepxe7WAovGk2RDlmuXluh6tPIBO phhuFvtWaLVEXTHorpJXEWHGWB4wBmGQow== X-Received: by 2002:a05:6000:1545:: with SMTP id 5mr28560232wry.90.1615299450367; Tue, 09 Mar 2021 06:17:30 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g9sm25577895wrp.14.2021.03.09.06.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 06:17:28 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2F9891FF87; Tue, 9 Mar 2021 14:17:28 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 1/4] semihosting: move semihosting tests to multiarch Date: Tue, 9 Mar 2021 14:17:24 +0000 Message-Id: <20210309141727.12522-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210309141727.12522-1-alex.bennee@linaro.org> References: <20210309141727.12522-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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 , keithp@keithp.com, "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" It may be arm-compat-semihosting but more than one architecture uses it so lets move the tests into the multiarch area. We gate it on the feature and split the semicall.h header between the arches. Also clean-up a bit of the Makefile messing about to one common set of runners. Signed-off-by: Alex Bennée --- tests/tcg/aarch64/semicall.h | 18 +++++++++++ tests/tcg/arm/semicall.h | 15 +-------- tests/tcg/riscv64/semicall.h | 22 +++++++++++++ .../arm-compat-semi}/semiconsole.c | 2 ++ .../arm-compat-semi}/semihosting.c | 5 ++- tests/tcg/Makefile.target | 3 ++ tests/tcg/aarch64/Makefile.target | 18 ----------- tests/tcg/arm/Makefile.target | 16 ++-------- tests/tcg/multiarch/Makefile.target | 31 +++++++++++++++++++ 9 files changed, 83 insertions(+), 47 deletions(-) create mode 100644 tests/tcg/aarch64/semicall.h create mode 100644 tests/tcg/riscv64/semicall.h rename tests/tcg/{arm => multiarch/arm-compat-semi}/semiconsole.c (93%) rename tests/tcg/{arm => multiarch/arm-compat-semi}/semihosting.c (85%) -- 2.20.1 diff --git a/tests/tcg/aarch64/semicall.h b/tests/tcg/aarch64/semicall.h new file mode 100644 index 0000000000..8a3fce35c5 --- /dev/null +++ b/tests/tcg/aarch64/semicall.h @@ -0,0 +1,18 @@ +/* + * Semihosting Tests - AArch64 helper + * + * Copyright (c) 2019 + * Written by Alex Bennée + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) +{ + register uintptr_t t asm("x0") = type; + register uintptr_t a0 asm("x1") = arg0; + asm("hlt 0xf000" + : "=r" (t) + : "r" (t), "r" (a0)); + return t; +} diff --git a/tests/tcg/arm/semicall.h b/tests/tcg/arm/semicall.h index d4f6818192..ad8ac51310 100644 --- a/tests/tcg/arm/semicall.h +++ b/tests/tcg/arm/semicall.h @@ -1,5 +1,5 @@ /* - * Semihosting Tests + * Semihosting Tests - ARM Helper * * Copyright (c) 2019 * Written by Alex Bennée @@ -7,13 +7,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -#define SYS_WRITE0 0x04 -#define SYS_READC 0x07 -#define SYS_REPORTEXC 0x18 - uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) { -#if defined(__arm__) register uintptr_t t asm("r0") = type; register uintptr_t a0 asm("r1") = arg0; #ifdef __thumb__ @@ -23,13 +18,5 @@ uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) #endif asm(SVC : "=r" (t) : "r" (t), "r" (a0)); -#else - register uintptr_t t asm("x0") = type; - register uintptr_t a0 asm("x1") = arg0; - asm("hlt 0xf000" - : "=r" (t) - : "r" (t), "r" (a0)); -#endif - return t; } diff --git a/tests/tcg/riscv64/semicall.h b/tests/tcg/riscv64/semicall.h new file mode 100644 index 0000000000..f8c88f32dc --- /dev/null +++ b/tests/tcg/riscv64/semicall.h @@ -0,0 +1,22 @@ +/* + * Semihosting Tests - RiscV64 Helper + * + * Copyright (c) 2021 + * Written by Alex Bennée + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) +{ + register uintptr_t t asm("a0") = type; + register uintptr_t a0 asm("a1") = arg0; + asm(".option norvc\n\t" + ".balign 16\n\t" + "slli zero, zero, 0x1f\n\t" + "ebreak\n\t" + "srai zero, zero, 0x7\n\t" + : "=r" (t) + : "r" (t), "r" (a0)); + return t; +} diff --git a/tests/tcg/arm/semiconsole.c b/tests/tcg/multiarch/arm-compat-semi/semiconsole.c similarity index 93% rename from tests/tcg/arm/semiconsole.c rename to tests/tcg/multiarch/arm-compat-semi/semiconsole.c index 6ef0bd2450..1d82efc589 100644 --- a/tests/tcg/arm/semiconsole.c +++ b/tests/tcg/multiarch/arm-compat-semi/semiconsole.c @@ -7,6 +7,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +#define SYS_READC 0x07 + #include #include #include "semicall.h" diff --git a/tests/tcg/arm/semihosting.c b/tests/tcg/multiarch/arm-compat-semi/semihosting.c similarity index 85% rename from tests/tcg/arm/semihosting.c rename to tests/tcg/multiarch/arm-compat-semi/semihosting.c index 33faac9916..b3fd16cd12 100644 --- a/tests/tcg/arm/semihosting.c +++ b/tests/tcg/multiarch/arm-compat-semi/semihosting.c @@ -7,12 +7,15 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +#define SYS_WRITE0 0x04 +#define SYS_REPORTEXC 0x18 + #include #include "semicall.h" int main(int argc, char *argv[argc]) { -#if defined(__arm__) +#if UINTPTR_MAX == UINT32_MAX uintptr_t exit_code = 0x20026; #else uintptr_t exit_block[2] = {0x20026, 0}; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 24d75a5801..cab8c6b3a2 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -32,6 +32,9 @@ all: -include ../../../config-host.mak -include ../config-$(TARGET).mak +ifeq ($(CONFIG_USER_ONLY),y) +-include $(SRC_PATH)/default-configs/targets/$(TARGET).mak +endif # for including , in command strings COMMA := , diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index bf53ad0087..56e48f4b34 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -41,24 +41,6 @@ AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-%: CFLAGS += -march=armv8.5-a+memtag endif -# Semihosting smoke test for linux-user -AARCH64_TESTS += semihosting -run-semihosting: semihosting - $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") - -run-plugin-semihosting-with-%: - $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ - -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ - $(call strip-plugin,$<) 2> $<.err, \ - "$< on $(TARGET_NAME) with $*") - -AARCH64_TESTS += semiconsole -run-semiconsole: semiconsole - $(call skip-test, $<, "MANUAL ONLY") - -run-plugin-semiconsole-with-%: - $(call skip-test, $<, "MANUAL ONLY") - ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_SVE),) # System Registers Tests AARCH64_TESTS += sysregs diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index ec95156562..1deda384df 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -30,37 +30,25 @@ run-fcvt: fcvt $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) # Semihosting smoke test for linux-user -ARM_TESTS += semihosting semihosting: CFLAGS += -mthumb -run-semihosting: semihosting - $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") ARM_TESTS += semihosting-arm semihosting-arm: CFLAGS += -marm -semihosting-arm: semihosting.c - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) run-semihosting-arm: semihosting-arm $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") -run-plugin-semihosting-with-%: +run-plugin-semihosting-arm-with-%: $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ $(call strip-plugin,$<) 2> $<.err, \ "$< on $(TARGET_NAME) with $*") -ARM_TESTS += semiconsole semiconsole-arm +ARM_TESTS += semiconsole-arm semiconsole: CFLAGS += -mthumb -run-semiconsole: semiconsole - $(call skip-test, $<, "MANUAL ONLY") - -run-plugin-semiconsole-with-%: - $(call skip-test, $<, "MANUAL ONLY") semiconsole-arm: CFLAGS += -marm -semiconsole-arm: semiconsole.c - $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) run-semiconsole-arm: semiconsole-arm $(call skip-test, $<, "MANUAL ONLY") diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index abbdb2e126..a3a751723d 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -69,6 +69,37 @@ run-gdbstub-%: endif EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read +# ARM Compatible Semi Hosting Tests +# +# Despite having ARM in the name we actually have several +# architectures that implement it. We gate the tests on the feature +# appearing in config. +# +ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y) +VPATH += $(MULTIARCH_SRC)/arm-compat-semi + +# Add -I path back to TARGET_NAME for semicall.h +semihosting: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME) + +run-semihosting: semihosting + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") + +run-plugin-semihosting-with-%: + $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ + -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ + $(call strip-plugin,$<) 2> $<.err, \ + "$< on $(TARGET_NAME) with $*") + +semiconsole: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME) + +run-semiconsole: semiconsole + $(call skip-test, $<, "MANUAL ONLY") + +run-plugin-semiconsole-with-%: + $(call skip-test, $<, "MANUAL ONLY") + +TESTS += semihosting semiconsole +endif # Update TESTS TESTS += $(MULTIARCH_TESTS) From patchwork Tue Mar 9 14:17:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 395998 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2626240jai; Tue, 9 Mar 2021 06:23:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxSMUgZEV65ZW92dQy6gMyYX+bpYqQOW3h1ZSlGwbm5WIcvsxaFSdlYVksXul3oAowXNzG X-Received: by 2002:a05:6638:3ba:: with SMTP id z26mr29478131jap.40.1615299780226; Tue, 09 Mar 2021 06:23:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615299780; cv=none; d=google.com; s=arc-20160816; b=wb/jC0R0L3Y9hDZW/qQbn5fmE8eGkUEni1CnCCXzyOkAdgN7ogQHoBXXPGiYd5O/3A LQBWVgmr6vyCZ9Ag3eWQlNv+iiVcDmUAU4JobmgWDQcFiw675pKZnSU1qE5kXo0cBz0S hKZG73DxlfaYotjITSSEpFw6RmD+SpUs81Cl1nuqYt0Chb0tMqI096bY4Q5UdupTWHKX JzrC89/2SiAr1mA7Sh+uB7ZfIkGWxFD2h5YGs0NwZGzXb4PDPt60NGQKrNBPXYiiDEj6 dSaoe93LyilTProkxz6mOofuX6BGnqESiHBBT0O/OnzluhWE04oH3N5R6cA6OtOmHJ/t ZeTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=joRSekChbA2FSdcIDUV4Rc5Up/Vr8KMhyFb2Cl5+fLs=; b=TkQHYp3m+hAt9iQpjAR4FVyc92BJExjXYvMSX0zaGRDugsblynjmeegpABYPfMiFDe 52DbizKfNa9aCPuglMeNWXwUq/THhKI69DSy604tqFPrMOGK4P6Ja0WWervc/xFe5vX+ lAAR5heCAjt0m9nCKTCbZfpX/H/b9B2lthQ7E6vshynTO4oIbhhUH9gSvyx4zuMLxTX0 AroDSEtjZ/xFJoSl55w5uf5AWwI+SVH0LA5/AVXEJT9+yPR+CjS4Dx/2uvQD9RznNRbL l+cecGuHPYxJbkIJ84Z8fFf19eUtSKq0cTOQqm+P+aswMv8mdZV8AWCs8ldh6JnXt8bq Q1Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y1F7PChO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b8si13870919ilf.79.2021.03.09.06.23.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Mar 2021 06:23:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y1F7PChO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJdGF-0005el-MP for patch@linaro.org; Tue, 09 Mar 2021 09:22:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJdB1-0001L9-KH for qemu-devel@nongnu.org; Tue, 09 Mar 2021 09:17:35 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:46684) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJdAz-0001iF-Ka for qemu-devel@nongnu.org; Tue, 09 Mar 2021 09:17:35 -0500 Received: by mail-wr1-x433.google.com with SMTP id a18so15867609wrc.13 for ; Tue, 09 Mar 2021 06:17:33 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=joRSekChbA2FSdcIDUV4Rc5Up/Vr8KMhyFb2Cl5+fLs=; b=y1F7PChOqkextOtYB9k8YXreCJZDMUJTnF09fdfiqUsT9KVHeycKhkKrmgem+PATYJ ZRpixpTuHgTo6zbOeZLSFgUaVAUCPdjtdmEcVxoZ87OHugCKTGOsHA2J01fKmkn41qrz 4sCHYGLUWbQ4mnikoDBfu7sI1S3294svw9ECTaN4f5L45YMEFbHykgaJfrLZcMJ5tf0J /Z326dPqwQOimQLWgNKM8CrEKkodyi+xSVzRjEJRscTcFlKtcc2LnBLNirgsxxOPO2mz BTSnWWN4pu2lKfgUZhIPxvDuvz4k5j60asXjWSdCnxZAq9GzwDz5ZmkQR4W34auyCmdM Pixg== 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=joRSekChbA2FSdcIDUV4Rc5Up/Vr8KMhyFb2Cl5+fLs=; b=hu9Tntsrt9xuRv9QumdBprL97EQpGprgbcSmyqt6SUWacjbvmxWekrQXYOszvmVYnd 5pzHiJrvztMjn+gvd1LoMi135ulxejQXPJdQ3gJ58b4Gz4uYA1P2Tq2wMQjk8ps1YAEG re/YukPDVaXKQi9k4v9TC6JB0YjVKJHwzfhO/qNfzlXfARlNAQv5VpnOok7vsGm2vN9S PT3MhskIymzQjhOTJyY7Lc0cmZdczTiffeA3myv8uu8i/ojYyNQ+ipqUVWoYE5rpnADV IHMZhW0+cTGUkkFeZbzkNcT65Q9SwC33qZWFHrsdE0ZisDQL/sc0lf8r2vVJbt+9kABR ClvQ== X-Gm-Message-State: AOAM531umJh6PYKULEZ2LsIezQ//0Tz884eots8NGHRU9UEsQQioSDao EzE5u9sPzS2Qs66PtX1EVFvMb23IhQ6mHw== X-Received: by 2002:adf:a406:: with SMTP id d6mr28779773wra.141.1615299452273; Tue, 09 Mar 2021 06:17:32 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z25sm4182503wmi.23.2021.03.09.06.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 06:17:28 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 470081FF8C; Tue, 9 Mar 2021 14:17:28 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 2/4] semihosting/arm-compat-semi: unify GET/SET_ARG helpers Date: Tue, 9 Mar 2021 14:17:25 +0000 Message-Id: <20210309141727.12522-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210309141727.12522-1-alex.bennee@linaro.org> References: <20210309141727.12522-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: keithp@keithp.com, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" >From the semihosting point of view what we want to know is the current mode of the processor. Unify this into a single helper and allow us to use the same GET/SET_ARG helpers for the rest of the code. Note: we aren't currently testing riscv32 due to missing toolchain for check-tcg tests. Signed-off-by: Alex Bennée --- semihosting/arm-compat-semi.c | 54 ++++++++++++----------------------- 1 file changed, 18 insertions(+), 36 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell Reviewed-by: Keith Packard diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 94950b6c56..733eea1e2d 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -767,15 +767,28 @@ static const GuestFDFunctions guestfd_fns[] = { }, }; -/* Read the input value from the argument block; fail the semihosting - * call if the memory read fails. +/* + * Read the input value from the argument block; fail the semihosting + * call if the memory read fails. Eventually we could use a generic + * CPUState helper function here. */ +static inline bool is_64bit_semihosting(CPUArchState *env) +{ #ifdef TARGET_ARM + return is_a64(env); +#elif defined(TARGET_RISCV) + return !riscv_cpu_is_32bit(env); +#else +#error un-handled architecture +#endif +} + + #define GET_ARG(n) do { \ - if (is_a64(env)) { \ + if (is_64bit_semihosting(env)) { \ if (get_user_u64(arg ## n, args + (n) * 8)) { \ errno = EFAULT; \ - return set_swi_errno(cs, -1); \ + return set_swi_errno(cs, -1); \ } \ } else { \ if (get_user_u32(arg ## n, args + (n) * 4)) { \ @@ -786,41 +799,10 @@ static const GuestFDFunctions guestfd_fns[] = { } while (0) #define SET_ARG(n, val) \ - (is_a64(env) ? \ + (is_64bit_semihosting(env) ? \ put_user_u64(val, args + (n) * 8) : \ put_user_u32(val, args + (n) * 4)) -#endif -#ifdef TARGET_RISCV - -/* - * get_user_ual is defined as get_user_u32 in softmmu-semi.h, - * we need a macro that fetches a target_ulong - */ -#define get_user_utl(arg, p) \ - ((sizeof(target_ulong) == 8) ? \ - get_user_u64(arg, p) : \ - get_user_u32(arg, p)) - -/* - * put_user_ual is defined as put_user_u32 in softmmu-semi.h, - * we need a macro that stores a target_ulong - */ -#define put_user_utl(arg, p) \ - ((sizeof(target_ulong) == 8) ? \ - put_user_u64(arg, p) : \ - put_user_u32(arg, p)) - -#define GET_ARG(n) do { \ - if (get_user_utl(arg ## n, args + (n) * sizeof(target_ulong))) { \ - errno = EFAULT; \ - return set_swi_errno(cs, -1); \ - } \ - } while (0) - -#define SET_ARG(n, val) \ - put_user_utl(val, args + (n) * sizeof(target_ulong)) -#endif /* * Do a semihosting call. From patchwork Tue Mar 9 14:17:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 395997 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2626013jai; Tue, 9 Mar 2021 06:22:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+EKNsXhR8+FOdiOglJnJyzYHT8/jBN+OG/OWnxDf+XFjvJbgfn0/XNj57bBSVJE5biYkd X-Received: by 2002:a92:760c:: with SMTP id r12mr25043908ilc.35.1615299759991; Tue, 09 Mar 2021 06:22:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615299759; cv=none; d=google.com; s=arc-20160816; b=co8oi+lDTH1yxTYSqNfZTEJ9SoCAydSz6e/bESLvBh9bUE954KUBGCLv4Gca2SbOkt /NE62h5ObTDUN2FxP94IbKdC1CJczfC7jmIcJg36t9SvQmPoxjlDhNEWc2sXITsyLubb whFxL9XGphE6uwzwM8EPNdImM9PM93OBkm8w84SiafZ6U7ANAoPZ8wiQgk3ZIql9Azjy P5gIua3S/Qrnvy0ZvUq0Eek/V2hUYfKIAdGsDghjih8jt3WYJAd9ZfnWUobcGshguKjT Nr3FBKNyvfcS94z6urWZnbMfzPXglX2rFKW5rpPDYOWcrjAebpPDddXjcK57tPdtWthZ Ez0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=nN/o3NC1BjCVaVugecWZFPBtRdcQ9Jd3TS2cKRxBLsA=; b=0DpgLpMrblYGZ/KyEz14M4eenrAv7JqRiiJOom+clNetnaomdSsgYUm9Dmcju/t6ph qbp+QbsXwHntXfyajVR5rJnzeR9judXxu4EPV6cQ30DR9DrZEYl/xWDpw6IZrrRxnpUR 2zVMv8eUcKQn4OxHdHD7MmZI6QKa6w3oSArvvTbp0Q0XhAyzJG3HUfaDSB2zleXsrGtp 9wK2HZQ9/IZEa5OipTUSF8JbrONGp8TiXjAUd+4WHfmhFnFTUQjuTjQAsyjHRdneZJjh TAmyg0yULZla02sK+WMY/9MUvdZvdvkO9g9moqVMA438kS/azCy8PCzFi4+R8Zrlb4OT SKVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Psti3gEG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n4si12568899ili.37.2021.03.09.06.22.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Mar 2021 06:22:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Psti3gEG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJdFv-0004oL-DY for patch@linaro.org; Tue, 09 Mar 2021 09:22:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJdB2-0001Ne-Ha for qemu-devel@nongnu.org; Tue, 09 Mar 2021 09:17:36 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:51748) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJdB0-0001ic-Qn for qemu-devel@nongnu.org; Tue, 09 Mar 2021 09:17:36 -0500 Received: by mail-wm1-x32e.google.com with SMTP id l22so2074385wme.1 for ; Tue, 09 Mar 2021 06:17:34 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=nN/o3NC1BjCVaVugecWZFPBtRdcQ9Jd3TS2cKRxBLsA=; b=Psti3gEGTHOBatFrhi4usMelQDLv5p8QRvNUVI/4Uoae3py2vs0WNWnGKO/nPJWwGm fSFSvl4Wf6kgg/LCrzn6tQMNHbqv4U2OfSPobYy5r5VCtsDvfBQ6ouoZqmG9ixhIx1cm 4qx83HoQ7fjQDSuK1qq3w5UEPZZFx7XvQIyiNhsUP4l9iLamqrrvPbsWJ5qHPF+pRRlo mYv1wpajO6eViNo/iac3GoKje1tbICYAl8ed7MdRF7+UHFk4SQdbqBFaplXClBwKzsGN BMPn9SGGsWCdjIJ0rZktraW0rHVZPAUZxyEuSB41OniVQFzlRyPGAYzyCCzAcZx2NY5m I8/A== 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=nN/o3NC1BjCVaVugecWZFPBtRdcQ9Jd3TS2cKRxBLsA=; b=RGvaz88DW0K3UYJtyiVQwFozdYT9C711UU2KvZTU23Ak9YK3vVIAjj0zbS/YeHS7SG wUYe0+uzGpEbAd8garQ+G+t/lhUrMOgyFN6OJcW08bTnHcVt9A6/d/GtsSqgBqXL0An3 jh1a3EwOp4UAidU0jWwkjIta9oye11Oltdnd1I2jC5Y1kEVcIlq9rTS/aa47NzIibizX WhB+0GOMISTQBLBNU58W6BGDt9ovI01aOXUpetsueZ2DQLs2tNCZpf6E1l40xyU3/kZM XvSius3EF8vBANvaXArMXkHSQwjvfhpPEUOair8fRtiuN7CszB2RVplTIJCKTaA3MyvW TynA== X-Gm-Message-State: AOAM533vcxAMvzK7/bKZ+bfZ3qPr4qwNV7PfCFN7X8yjmPL+LY1J/xQI DcB3HHqwxXOEwipHTsOqk+l0uQ== X-Received: by 2002:a05:600c:4ba2:: with SMTP id e34mr4308715wmp.121.1615299453372; Tue, 09 Mar 2021 06:17:33 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f22sm4147037wmc.33.2021.03.09.06.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 06:17:31 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5CB931FF8F; Tue, 9 Mar 2021 14:17:28 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 3/4] semihosting/arm-compat-semi: deref parameter register for SYS_HEAPINFO Date: Tue, 9 Mar 2021 14:17:26 +0000 Message-Id: <20210309141727.12522-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210309141727.12522-1-alex.bennee@linaro.org> References: <20210309141727.12522-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Bug 1915925 <1915925@bugs.launchpad.net>, keithp@keithp.com, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As per the spec: the PARAMETER REGISTER contains the address of a pointer to a four-field data block. So we need to follow the pointer and place the results of SYS_HEAPINFO there. Bug: https://bugs.launchpad.net/bugs/1915925 Cc: Bug 1915925 <1915925@bugs.launchpad.net> Cc: Keith Packard Signed-off-by: Alex Bennée --- semihosting/arm-compat-semi.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.20.1 diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 733eea1e2d..2ac9226d29 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -1210,6 +1210,8 @@ target_ulong do_common_semihosting(CPUState *cs) retvals[2] = rambase + limit; /* Stack base */ retvals[3] = rambase; /* Stack limit. */ #endif + /* The result array is pointed to by arg0 */ + args = arg0; for (i = 0; i < ARRAY_SIZE(retvals); i++) { bool fail; From patchwork Tue Mar 9 14:17:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 395995 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2624127jai; Tue, 9 Mar 2021 06:20:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzc/MJ5xVq/uErgwUza413EgyebnIp2KlenNMXHB2dSJ+DrXQwPlU21XK8dQn+Zdi+Ye/u7 X-Received: by 2002:ab0:608a:: with SMTP id i10mr15853043ual.26.1615299615452; Tue, 09 Mar 2021 06:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615299615; cv=none; d=google.com; s=arc-20160816; b=E44v1IIzVnW0Z5wOLuS1eLNaJ8vA18iQ3SSo8593lw3hk73BMqtDp4X3kQXBvfPeTx yUPW+zXqFxSU3xvgEj9RxGzIqmwLEjr4xVTXWeySF3M8zpaM90R8rYoiD3cgd2xTsB36 b8DPPU+5iAH+jCAKD/4iDHXoi9MhnZUHcE67Y08vfwihMqCYp6YbJuDpb0J+NZAIt8dU i65/CgXHcrDoaHY30olMgdyOQrxwNNl8oBRGC14qdfJplZt5z6HCZ0CdIaBeOfZ6yDVL 6PyKx1lNhq7i1POt1t9HTQl13HI7fnhb8R5347DsrlHPmawrmCFz3ytoBJ6P5/QyBk9h UbqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=H2Dg/3xWo/lJhWRHAFHTsEix8OkL3E+jnOBvruDCvb4=; b=a7PUBSg5o5PaoEnOkGlU2NOnDBizyZhew+T3pLUG52igbGInndtUd/vX6/qhzkEBlJ nIRjiRyIne+/FlSNEH5elv+ZqOYm/d+24LagMJk92qv5Eg2aVX6vpaRK/cVa3UTH06qM ka5EAo174qRWlgSnU+UoEtWdZac6Ws0CpnGdnUfv5GMCK5jUuLOkf56yXmBE4mWwgjBZ QS5X/JRSmi4TiPJky57vL+Euzsbn3mWFDw923g27wsjYoAA0D3q/cNLjn6ei2v7bZwLB 7Veg5J+KP6dkom9hIP/x3+MVCgEcOoUH4oXx1AzoEURGvHuQM/nbtCjdkYkxTs2+kzOS L/xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zcVJQeh1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t142si2317307vst.41.2021.03.09.06.20.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Mar 2021 06:20:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zcVJQeh1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJdDa-0003oE-Oc for patch@linaro.org; Tue, 09 Mar 2021 09:20:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJdB8-0001SU-4x for qemu-devel@nongnu.org; Tue, 09 Mar 2021 09:17:42 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:33185) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJdB2-0001kS-IL for qemu-devel@nongnu.org; Tue, 09 Mar 2021 09:17:41 -0500 Received: by mail-wr1-x42e.google.com with SMTP id 7so15945769wrz.0 for ; Tue, 09 Mar 2021 06:17:36 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=H2Dg/3xWo/lJhWRHAFHTsEix8OkL3E+jnOBvruDCvb4=; b=zcVJQeh11ElxEEP2NEQY6o+fNY8R5wSXDGT2s5+SYVoGgnlwGYtmvkrTk5GhjGxdUH su5feLN+xebiZNIehZi6kfqoK0ciq2QKT27HWHnqfEWkwc9zFT0ITOyl6cYR1J7G3NL0 S75gF/OnPbvF8jb1yYZ3hhUt65m0r3kTT77KvQyPRbYOemxKWo3PQfFlfwbkyyr2DOoA ryrob9Y9tAx4uugxRUAadZcsSJF+kmZTpWbTtHqpM9BpYfkwiBEoTDQXsBhMlDNjzNhs 963Dh06VRpLdm+F1H8Tjqso8EzNubcGmSHV1hxfyBAzMeA9ylV1sk0W+6ukbrB8isjF+ 31xg== 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=H2Dg/3xWo/lJhWRHAFHTsEix8OkL3E+jnOBvruDCvb4=; b=rBDvFmze07cNBVA+Y8NujuNJm4dGElbRGerjpS5OjukKSqlR5Vlrm8CbHbSxQGNuzo +zXtFxz2RcMtzSbFSAk07vVmLfc1mXwePKl7AqmxA3YjrMg0JPmCw6vWaAss3N/3W17B NxfAZvljELMpxv4tzD7garEsf5swgkF+uQilhMH4Nzk7JHAoIiUjKaR+bOOnuasaHF8m mguRAcuavHUmzi+QGYaJERWzk1Uc7QjcJ5cMe9/vo9MuDRCt6cuwE4zlQMaekFKP31jN NXuxgBxysonOoo6aOiqSbaB5ufiR/A9KSIXEeQNGRilrA9z3w+4m6+t2wbLm95HKrGba Es8Q== X-Gm-Message-State: AOAM531HAzJBnlcqSAwVBcXXAXVYWGl6gcYiv9+aeJhEU1lXFa/Jyoo2 g8aC8OqK0pz8TQyTtJJ5pBjAqw== X-Received: by 2002:a05:6000:10c3:: with SMTP id b3mr27984166wrx.96.1615299455271; Tue, 09 Mar 2021 06:17:35 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s9sm4462706wmh.31.2021.03.09.06.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 06:17:32 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 70E421FF90; Tue, 9 Mar 2021 14:17:28 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 4/4] tests/tcg: add HeapInfo checking to semihosting test Date: Tue, 9 Mar 2021 14:17:27 +0000 Message-Id: <20210309141727.12522-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210309141727.12522-1-alex.bennee@linaro.org> References: <20210309141727.12522-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: keithp@keithp.com, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Query the SYS_HEAPINFO semicall and do some basic verification of the information via libc calls. Signed-off-by: Alex Bennée --- .../multiarch/arm-compat-semi/semihosting.c | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/tests/tcg/multiarch/arm-compat-semi/semihosting.c b/tests/tcg/multiarch/arm-compat-semi/semihosting.c index b3fd16cd12..5fa3c0a82d 100644 --- a/tests/tcg/multiarch/arm-compat-semi/semihosting.c +++ b/tests/tcg/multiarch/arm-compat-semi/semihosting.c @@ -8,9 +8,16 @@ */ #define SYS_WRITE0 0x04 +#define SYS_HEAPINFO 0x16 #define SYS_REPORTEXC 0x18 +#define _GNU_SOURCE /* asprintf is a GNU extension */ + #include +#include +#include +#include +#include #include "semicall.h" int main(int argc, char *argv[argc]) @@ -21,8 +28,34 @@ int main(int argc, char *argv[argc]) uintptr_t exit_block[2] = {0x20026, 0}; uintptr_t exit_code = (uintptr_t) &exit_block; #endif + struct { + void *heap_base; + void *heap_limit; + void *stack_base; + void *stack_limit; + } info; + void *ptr_to_info = (void *) &info; + char *heap_info, *stack_info; + void *brk = sbrk(0); + + __semi_call(SYS_WRITE0, (uintptr_t) "Checking HeapInfo\n"); + + memset(&info, 0, sizeof(info)); + __semi_call(SYS_HEAPINFO, (uintptr_t) &ptr_to_info); + + asprintf(&heap_info, "heap: %p -> %p\n", info.heap_base, info.heap_limit); + __semi_call(SYS_WRITE0, (uintptr_t) heap_info); + if (info.heap_base != brk) { + sprintf(heap_info, "heap mismatch: %p\n", brk); + __semi_call(SYS_WRITE0, (uintptr_t) heap_info); + return -1; + } + + asprintf(&stack_info, "stack: %p -> %p\n", info.stack_base, info.stack_limit); + __semi_call(SYS_WRITE0, (uintptr_t) stack_info); + free(heap_info); + free(stack_info); - __semi_call(SYS_WRITE0, (uintptr_t) "Hello World"); __semi_call(SYS_REPORTEXC, exit_code); /* if we get here we failed */ return -1;