From nobody Tue May 7 23:08:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1563198176; cv=none; d=zoho.com; s=zohoarc; b=Uzxp9npyN/arjM4lC/ORFinxnNUxwoZl1Hr+vJgByWrYQlubeBXlm1cXqdGPN3pSvsfFJDhlqJs2h3MI90OKO4xXiqJH6fd4NvVnTLr7Ya8W8QC3nQfJOZvJqKOuane8mWBYqJ7wTC0oQ3lUzQin1DVLUPO+NQ7wsN1Enc1oxiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563198176; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=vAsiB4hjT86jOZ/YYLR/hX2fOxLZe4WaIVAdFxNA9qQ=; b=UTPItssFI95cUFvDJ+Krfy/9UttpUnUVKwoVkPCbSLRtiPntasVoUemDWMgSjTXknrFC8gcGaNwONayE9cvA5FIMITcU0ak9pOdkzJjzeVyEMbKZ/ms8r0MSy2jnd8ZuNgxNm9cVXVLnTx20CVPdPGJDyaA4NsaFYuT9mLmry2U= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15631981760411014.346039862074; Mon, 15 Jul 2019 06:42:56 -0700 (PDT) Received: from localhost ([::1]:38714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1Fm-00017r-Lb for importer@patchew.org; Mon, 15 Jul 2019 09:42:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51752) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1FF-0007n7-PA for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1FE-0006A3-MQ for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:21 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:51646) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn1FC-00067L-1F for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:18 -0400 Received: by mail-wm1-x344.google.com with SMTP id 207so15246878wma.1 for ; Mon, 15 Jul 2019 06:42:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c7sm14221808wro.70.2019.07.15.06.42.13 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 06:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vAsiB4hjT86jOZ/YYLR/hX2fOxLZe4WaIVAdFxNA9qQ=; b=zLlw2+RTdcaSU/3nV+ab9934WQAiBnD3VI3Y854a8tzPCa9vIKeXe89D0wTBfZJ/qJ 34NwG5LfIKfJW0Be2olDlCoLv4lV4dfWbb9j7bWhloswJryp+AyxrCl2kit3/bteEjFa M2tGAe4jqFL6dqeSTj7wh4CjObOYAqRPsRKdmk3dLy2kn+8nqoOn4vh2bxW+zDQ3o9O4 sKAT63Jc1pCJ88604uskGefqJYmpNKlE+THxjvKejznoe92exCr5xd1TO+2cz2BPYJKY +iWHt2OvD/iOoaptbM/gJjioa/Bt7QWYfVhv+/Y62w0gbjy/HVml0oD6ya1kYPqPx6GH 1ZLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vAsiB4hjT86jOZ/YYLR/hX2fOxLZe4WaIVAdFxNA9qQ=; b=BlNmRS4Nu3rnmZA20xkNnNHlg1afDAclJrFsaW1xgSHVOylv5ViLBLg3Jys5Qg56yG B5z1ctkLzk5KxS2Np53no1N/O1Xgl1ZuE0Rxg+M3MKm2GIYR/TFYJiEXPFyZOOUzW25M xqlwh5eAnPpcW3bOMw8PiEV03nhFRTuV4Y7txA05hdz/xUSoigDBIvGYDCKqq8HgB7Qo BXNty7EtPqjqKEUyXfH6XnU6NnmMJ/Gv1HTgK+eIAyweP7/DJYnbPRM7WlPb61g96PyG uoSqcsEK5es2Fm9VeJvvJJ/r6t4pguCzhhCeKKzIqa8pLFPpvv1a7N7Hr0bgiIQL4C/s b9cA== X-Gm-Message-State: APjAAAXs99JhdKUPqzq4uoMWC6bSiv1aXOYhLcvwfcAMiMIG4hjSj9Q8 /R5MdPBxXfsELfPRcItKkLJbROvmr8Ol6g== X-Google-Smtp-Source: APXvYqylDhIOUWbQHrXKFnDe+s1VDHsS/gm37+4WRvKrcyu/EQ4d8BAJuqAIAjZ88U9qXtGEcfEWnA== X-Received: by 2002:a05:600c:2549:: with SMTP id e9mr23218602wma.46.1563198133890; Mon, 15 Jul 2019 06:42:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 14:42:02 +0100 Message-Id: <20190715134211.23063-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134211.23063-1-peter.maydell@linaro.org> References: <20190715134211.23063-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PULL 01/10] target/arm: report ARMv8-A FP support for AArch32 -cpu max 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alex Benn=C3=A9e When we converted to using feature bits in 602f6e42cfbf we missed out the fact (dp && arm_dc_feature(s, ARM_FEATURE_V8)) was supported for -cpu max configurations. This caused a regression in the GCC test suite. Fix this by setting the appropriate bits in mvfr1.FPHP to report ARMv8-A with FP support (but not ARMv8.2-FP16). Fixes: https://bugs.launchpad.net/qemu/+bug/1836078 Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-id: 20190711103737.10017-1-alex.bennee@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index e75a64a25a4..ad164a773b2 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2452,6 +2452,10 @@ static void arm_max_initfn(Object *obj) t =3D FIELD_DP32(t, ID_ISAR6, SPECRES, 1); cpu->isar.id_isar6 =3D t; =20 + t =3D cpu->isar.mvfr1; + t =3D FIELD_DP32(t, MVFR1, FPHP, 2); /* v8.0 FP support */ + cpu->isar.mvfr1 =3D t; + t =3D cpu->isar.mvfr2; t =3D FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ t =3D FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ --=20 2.20.1 From nobody Tue May 7 23:08:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1563198208; cv=none; d=zoho.com; s=zohoarc; b=PlHwo6rMqOm9X7/TMu3WpbCjJI1zCgcBGuP7c0BfiKMrJfaQ42qXg+crBnsTyS9HoAb50MxodFMuYjbWruWcFUxpgltcS1EUXc28cVhX1OeqppbXoNVRUrWoCgD5vQHJGI8LFajkdw1y6xjZbnDUT35bSeHb71pq1x4DX0zDFD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563198208; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=cZNM3b90C0KI7GS3KaL+3KknzrTXZsMagrLfxlk+ajU=; b=imtCR/ne6Iewhlc6SC+tAH1oEE92uIQLxirSbEQtQA8RxgvOaSz3IAYLfFaDLk41FHIRTxq4MxtXeZenGTTTVafcd247Aj/koI/8cs8SQCC+8I5NeTYnCV0oiGmIfaXvUtjbbkXiWSt9CnST57tlIrqdiK9jSNLW+PWobiV0uJA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563198208917234.6123493426362; Mon, 15 Jul 2019 06:43:28 -0700 (PDT) Received: from localhost ([::1]:38738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1GJ-0003Z3-DM for importer@patchew.org; Mon, 15 Jul 2019 09:43:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51746) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1FF-0007mO-L0 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1FE-0006A7-Mg for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:21 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:40739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn1FC-00067e-1S for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:18 -0400 Received: by mail-wm1-x341.google.com with SMTP id v19so15275585wmj.5 for ; Mon, 15 Jul 2019 06:42:16 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c7sm14221808wro.70.2019.07.15.06.42.13 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 06:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cZNM3b90C0KI7GS3KaL+3KknzrTXZsMagrLfxlk+ajU=; b=otxZc/mtaOuA7Lkvv9rjj9HKjelnjfwkFJQu7Y9VlKFOp6WPj42XYCSIloW+OgH5eT YkO2OlC8a8DURpPPbCBJ27oIOPqPEm+6zj2AVs70SzgLT3vDsHZQgAAKTM1ZJ4xAt21T 7krDirQh1GpaD864eMhEhtDCLsBxDDgaOoF1qSgp6XP9TGgu21C3thFMZpoFo+G6CIoY r2+OPAETIVK+2U4nan2IiKWEDDSlejEhvK1q8paV9XfcRXiPSbivJOVfAIrO020j2CRB 3JSUfoJkhu3UzHYHCDwPcLkFse5+wfXHwgQMjLKz0NZxSXWGsKRBHK+gWt2eBqEp7szq rjhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cZNM3b90C0KI7GS3KaL+3KknzrTXZsMagrLfxlk+ajU=; b=jMf7GVdDhdw+3wojs/YJnUsHZGNj0jWiDuSweqc9U53wfc8WS7TanpoSTW65v4Vu/0 iCh4fPY9YW/vDb6xmiYvBu5Szq7SKCpqbz2+5fI2scVoNqUJffymC+HgTy/mYU1YWW3R ZNlJ89vajhCRiauWLWd9JrPKiEU2l3IvPwKvW1MZdsKQePHbu2+pVKetc1xV3dIvhLsy /23ebRbuuoi9Yzu69bwPVH/ckHMLTWciL/xZJJ1ruUnGbSxY2YkrVARWDML0JqIlOQtE s9pde+BbggOwOgO66CM1tNuf/3ly2MryMYw9RSdS+GPitSzxrmxHS6vkc8Atz8fXWeC2 wpeg== X-Gm-Message-State: APjAAAUwPuDzcjZ5gRVMXeYDzWDXSXROVb25BySCr74mNrLqCCf6ryZe 4WybnLYuu3IAlUZXQhMuaqI00cpcNN893Q== X-Google-Smtp-Source: APXvYqyEekqB2pH4T8kJYxFYkCaYK7OYbT75TzPxT3yJ8GpBMO9dQjWn3tSegTqCAkHnk1YfmLQzjQ== X-Received: by 2002:a1c:c742:: with SMTP id x63mr26250512wmf.0.1563198135022; Mon, 15 Jul 2019 06:42:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 14:42:03 +0100 Message-Id: <20190715134211.23063-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134211.23063-1-peter.maydell@linaro.org> References: <20190715134211.23063-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PULL 02/10] hw/ssi/xilinx_spips: Convert lqspi_read() to read_with_attrs 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 In the next commit we will implement the write_with_attrs() handler. To avoid using different APIs, convert the read() handler first. Reviewed-by: Francisco Iglesias Tested-by: Francisco Iglesias Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Maydell --- hw/ssi/xilinx_spips.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c index 8115bb6d468..b7c7275dbe4 100644 --- a/hw/ssi/xilinx_spips.c +++ b/hw/ssi/xilinx_spips.c @@ -1202,27 +1202,26 @@ static void lqspi_load_cache(void *opaque, hwaddr a= ddr) } } =20 -static uint64_t -lqspi_read(void *opaque, hwaddr addr, unsigned int size) +static MemTxResult lqspi_read(void *opaque, hwaddr addr, uint64_t *value, + unsigned size, MemTxAttrs attrs) { - XilinxQSPIPS *q =3D opaque; - uint32_t ret; + XilinxQSPIPS *q =3D XILINX_QSPIPS(opaque); =20 if (addr >=3D q->lqspi_cached_addr && addr <=3D q->lqspi_cached_addr + LQSPI_CACHE_SIZE - 4) { uint8_t *retp =3D &q->lqspi_buf[addr - q->lqspi_cached_addr]; - ret =3D cpu_to_le32(*(uint32_t *)retp); - DB_PRINT_L(1, "addr: %08x, data: %08x\n", (unsigned)addr, - (unsigned)ret); - return ret; - } else { - lqspi_load_cache(opaque, addr); - return lqspi_read(opaque, addr, size); + *value =3D cpu_to_le32(*(uint32_t *)retp); + DB_PRINT_L(1, "addr: %08" HWADDR_PRIx ", data: %08" PRIx64 "\n", + addr, *value); + return MEMTX_OK; } + + lqspi_load_cache(opaque, addr); + return lqspi_read(opaque, addr, value, size, attrs); } =20 static const MemoryRegionOps lqspi_ops =3D { - .read =3D lqspi_read, + .read_with_attrs =3D lqspi_read, .endianness =3D DEVICE_NATIVE_ENDIAN, .valid =3D { .min_access_size =3D 1, --=20 2.20.1 From nobody Tue May 7 23:08:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1563198178; cv=none; d=zoho.com; s=zohoarc; b=TZxHzKVkQFEZIqn05nE3rMyGayqB/naqwQk24VCK9c2RpvmwGqvaj/rjh9vEhx5e29gY6Vkq8WABDgTxJM68Srcj6+RtpYJdKvs67ZLKAqdwwBxetuj6MfKwDuyZaQPLxlKwXsAPpsHcdy4vnUo3JHuCAfjb7cOhnb1lz6i+tzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563198178; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=SRhHW3p+BKr58tLhFiUoR21pNGFw1vt263k2cYakmhQ=; b=IdPuIbeZU8uLfNWuvpZSK2C9sQFBOWfT5T4ygDaNt2frN2ndqP7InF1/eabZXug9jt0ibPFgecs2QzIjDAnXqIwUAPwdVqmR/Sgf/a3lxlPqfbNWEsAjwqaF4ajq5H9As9V4Sp5lWo2aee3tK4Z2R4QpGQkVuHqrDgPRne2OFJE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563198178757213.82588327503515; Mon, 15 Jul 2019 06:42:58 -0700 (PDT) Received: from localhost ([::1]:38719 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1Fp-0001I5-GE for importer@patchew.org; Mon, 15 Jul 2019 09:42:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51721) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1FE-0007lA-Ua for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1FD-00069O-5J for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:20 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:50258) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn1FB-000682-LO for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:18 -0400 Received: by mail-wm1-x329.google.com with SMTP id v15so15252331wml.0 for ; Mon, 15 Jul 2019 06:42:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c7sm14221808wro.70.2019.07.15.06.42.15 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 06:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=SRhHW3p+BKr58tLhFiUoR21pNGFw1vt263k2cYakmhQ=; b=h3lc+ztoxeXOSl05jAM7rqFEc9nxQw6ot8kKvvMx87rJLydY17kr43R3zA+6F4Hjex UBBqJKdPtMAV3bYyK7O9LRWmpMmMrf3mcB8FTMqIR/a53pk2JPlUkeNjrhir8dTU3XHP X6sl96dV4A+wpd9yLnLI0KLnmwNrERverd8W7Qodw5j6tw1xAqFL7rNBcdt3DLzY9po0 FAVhDl5/VoKQ0oChRhfgEhQqAOoEpyU4uU+CRKloBkDrh5d1EvpqypJpO3T9ZS/uLPI3 0yucOIa5rUm3SEWsI/3WbVKVn+sVrOIlA6VO6dic5jKVou+2jLt4FV6Ss+JDU9ltts+4 +grQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SRhHW3p+BKr58tLhFiUoR21pNGFw1vt263k2cYakmhQ=; b=jdXiAmnCXsGarx6jqoDopOz7cgVVY5wprnUrhpfGPKFtMNPT7s2/1YuCIZ0Sz01EYD FVuQZvF8WgORp8jnQFXe1Upk6wzbh3OHnjUpkHU4smAymsjM3WwQNvvb7WOiEpL64fQy wXrPVNyuvsUlOozWtMmvLOQvpQOUBl8gZKjWpGESzf+Th9ZiY50XlYTsS5Fsfask9vFH EZP0MRNbZ335mqqWjKJ4f8zZG3QsLytpAUPoRq4xW7MVdSJwHQdzfnJSb+8rrgrfF8Iw olHYX/FyNXhBrdLKJ2PgW0SV4IgoawtQtUZ6LKPhprHMkDUy0P3a4wqOyfrHC3U/jHne VAWw== X-Gm-Message-State: APjAAAW4hY78bI2qx/YXyRjBIwTdY4YP0CpY7I+IYj9Wsbhq8jc3ROce LRjdSEzuOU0p32oYiEnYaJeG1TeerINjTQ== X-Google-Smtp-Source: APXvYqyvZPJ+z62DNTyRh9V0oA+rh6qctpzUQvaqrNxehe06XBBo8XfVC7RT79k3JS3YTkg4Zcbgwg== X-Received: by 2002:a1c:b155:: with SMTP id a82mr23805926wmf.35.1563198135847; Mon, 15 Jul 2019 06:42:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 14:42:04 +0100 Message-Id: <20190715134211.23063-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134211.23063-1-peter.maydell@linaro.org> References: <20190715134211.23063-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 Subject: [Qemu-devel] [PULL 03/10] hw/ssi/xilinx_spips: Avoid AXI writes to the LQSPI linear memory 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Lei Sun found while auditing the code that a CPU write would trigger a NULL pointer dereference. >From UG1085 datasheet [*] AXI writes in this region are ignored and generates an AXI Slave Error (SLVERR). Fix by implementing the write_with_attrs() handler. Return MEMTX_ERROR when the region is accessed (this error maps to an AXI slave error). [*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ul= trascale-trm.pdf Reported-by: Lei Sun Reviewed-by: Francisco Iglesias Tested-by: Francisco Iglesias Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Maydell --- hw/ssi/xilinx_spips.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c index b7c7275dbe4..3c4e8365ee1 100644 --- a/hw/ssi/xilinx_spips.c +++ b/hw/ssi/xilinx_spips.c @@ -1220,8 +1220,24 @@ static MemTxResult lqspi_read(void *opaque, hwaddr a= ddr, uint64_t *value, return lqspi_read(opaque, addr, value, size, attrs); } =20 +static MemTxResult lqspi_write(void *opaque, hwaddr offset, uint64_t value, + unsigned size, MemTxAttrs attrs) +{ + /* + * From UG1085, Chapter 24 (Quad-SPI controllers): + * - Writes are ignored + * - AXI writes generate an external AXI slave error (SLVERR) + */ + qemu_log_mask(LOG_GUEST_ERROR, "%s Unexpected %u-bit access to 0x%" PR= Ix64 + " (value: 0x%" PRIx64 "\n", + __func__, size << 3, offset, value); + + return MEMTX_ERROR; +} + static const MemoryRegionOps lqspi_ops =3D { .read_with_attrs =3D lqspi_read, + .write_with_attrs =3D lqspi_write, .endianness =3D DEVICE_NATIVE_ENDIAN, .valid =3D { .min_access_size =3D 1, --=20 2.20.1 From nobody Tue May 7 23:08:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1563198222; cv=none; d=zoho.com; s=zohoarc; b=hnZ5Q/QFZVLsOUVSgp1zxrIRcTUhqgsYuP7KPXyI3IWwi86ebn/xte0+3Yov83XHp7t50D1oZOVibxQYLPze1CNmxzwjqjMvK2O6IVZC4yyC5y+LWqylulobRCiTDmw/A2bktg7LCRkRihycM2QGfh2VxU5Nk94oB1NKqwBY7Hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563198222; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=L2IhKlit3pXJDd+/6R6m/mSK1+w4V2YJU+DGORWiSMg=; b=FrGCkiFyGfF6uVmZErQ+82UkNwE16UVNcBFo6fipqnzE2pLcQBZTUvG6lEck11efKz+ct5oV/GF3+YaVUnYn+oQ1x5cXeezXLS3/6AvjZMR9I+mVylq8VOVQQr10g3YO8CsvoDDEb5EIeWHDW0/fX23C1M2+9xE9o1cxo7f81vE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563198222114140.11717384890676; Mon, 15 Jul 2019 06:43:42 -0700 (PDT) Received: from localhost ([::1]:38742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1GW-0004Zu-JD for importer@patchew.org; Mon, 15 Jul 2019 09:43:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51759) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1FF-0007oG-Vq for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1FE-0006AR-UC for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:21 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:50263) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn1FC-00068b-Uf for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:20 -0400 Received: by mail-wm1-x32e.google.com with SMTP id v15so15252419wml.0 for ; Mon, 15 Jul 2019 06:42:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c7sm14221808wro.70.2019.07.15.06.42.15 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 06:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=L2IhKlit3pXJDd+/6R6m/mSK1+w4V2YJU+DGORWiSMg=; b=nWnlgsY+0S6B38l9dOW2G9sA2y5vmMYi8C5f1Mn21xdJ3GmSLtshqwFuSJlDEtSD6L HjMw4pQMQxS/0ZapAe0eDgJktaLFshXFItfDSD6/dJ/JK9ZxbFsi0qNg2ma4vNOhe+eJ bGELrVyTia6YjniCBg8+Yy8bB85XupSXTFXk6iefQQJI5pEsg/9elkVUrjkPT4P7ve3M 42bQY9rWIFIjrRy4DjtR0hPkHalcwLftaLON3RbdPd5oRT8Yy0Aq/3vGFiyZ3zyCM/l7 xfaUEuimMfNpX8V1r0X2tldGmSCo/CgZnj3mZGoFkOMisMs838LvP7smRSwyXb/O0g7a h+RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L2IhKlit3pXJDd+/6R6m/mSK1+w4V2YJU+DGORWiSMg=; b=HZEXzakCkmstQ0trWSVxVBusiDbcKKETetYlehI1JVGZLpReKAXcO1tEbXbHr5WXX4 Twe8F6dwO1ahOxOQO+8iro6rzgcAQ45/AGnRcaneFQ8TEGx3u5iDyNv/ajGYquDfmARh DBEsubA+cTQwgJ+lb9peEa9SJRbPGtcTM2tzI2esI5OMlmNnO/hZqh590FUxejbjsuj+ 67xXowEPyR8yRDSbML6QKO2CuaRLtA2CVCpyoGmNxW28DUQ0rSaHSikseFSFbUgF2Qrg 1TZ7BgGAdrPuB8+47llCMd6YCo/Ma/YojGaHlPC0Enufuh+0r1sSrDMkjrLfZ0X1I13f 9QSg== X-Gm-Message-State: APjAAAVRC5bjmX0rEq1FcCy3UhgDEdJGXp1+dAGFCP4z+zLfDIvtKrvx DKkTvYGiaHI5bp3jGt07G/Tt9wvkasUa8A== X-Google-Smtp-Source: APXvYqz2Yyib+vGkjvNfRv7bBaFsoFzOXVVMHViD+LWxyi9w8cnlWnI0lcs4evdBIHfx8mR52jrJuQ== X-Received: by 2002:a7b:ce01:: with SMTP id m1mr24706428wmc.1.1563198137172; Mon, 15 Jul 2019 06:42:17 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 14:42:05 +0100 Message-Id: <20190715134211.23063-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134211.23063-1-peter.maydell@linaro.org> References: <20190715134211.23063-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32e Subject: [Qemu-devel] [PULL 04/10] hw/ssi/xilinx_spips: Avoid out-of-bound access to lqspi_buf[] 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Both lqspi_read() and lqspi_load_cache() expect a 32-bit aligned address. >From UG1085 datasheet [*] chapter on 'Quad-SPI Controller': Transfer Size Limitations Because of the 32-bit wide TX, RX, and generic FIFO, all APB/AXI transfers must be an integer multiple of 4-bytes. Shorter transfers are not possible. Set MemoryRegionOps.impl values to force 32-bit accesses, this way we are sure we do not access the lqspi_buf[] array out of bound. [*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ul= trascale-trm.pdf Reviewed-by: Francisco Iglesias Tested-by: Francisco Iglesias Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Maydell --- hw/ssi/xilinx_spips.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c index 3c4e8365ee1..b29e0a4a89e 100644 --- a/hw/ssi/xilinx_spips.c +++ b/hw/ssi/xilinx_spips.c @@ -1239,6 +1239,10 @@ static const MemoryRegionOps lqspi_ops =3D { .read_with_attrs =3D lqspi_read, .write_with_attrs =3D lqspi_write, .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, .valid =3D { .min_access_size =3D 1, .max_access_size =3D 4 --=20 2.20.1 From nobody Tue May 7 23:08:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1563198177; cv=none; d=zoho.com; s=zohoarc; b=YM2AuDv0bpkifSS8h09GmBJXUnS4R5Uw+hEXAAspUyg0zJjGm6CIvI1EcPPW70Ty48gfsYc5qMMaNCnwe13D8f6ifwsY35Gs7rtPqwOkhQP2402oFrPfxx9AMksKhn63cLuQFsO05RdVbHcPY8VG1nhK1PvqmcCEuWalr1KZ6xA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563198177; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=M7cygNuQv/R1u8CJs+gp7c5R4DnZyamtxh5srkkTrmQ=; b=UToALzXs4qpvMwF38bJSdiTsX0Lps4ITdnUZBPczApNvIp5W0n0zoJONC+o/u/SgFcaK/QxNTvL5LHcErnIFivxucfSycB7rRBoF9AYHZ/5hLn8TLjA1PevUhecZ4RfhBkSVoBXELHBodw04auM7XaGMcVYMzRIScnshiB/GSjM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563198177493573.7760551723445; Mon, 15 Jul 2019 06:42:57 -0700 (PDT) Received: from localhost ([::1]:38716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1Fn-0001E3-K8 for importer@patchew.org; Mon, 15 Jul 2019 09:42:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51789) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1FG-0007sW-VH for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1FF-0006Ah-6E for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:22 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:51208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn1FE-000693-Rt for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:21 -0400 Received: by mail-wm1-x336.google.com with SMTP id 207so15247139wma.1 for ; Mon, 15 Jul 2019 06:42:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c7sm14221808wro.70.2019.07.15.06.42.17 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 06:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=M7cygNuQv/R1u8CJs+gp7c5R4DnZyamtxh5srkkTrmQ=; b=uyL6kkJrL5xDlguPEnMeJZn4TYutZ/hvvgUKVtFckiWXqDqR2hbbMAH0WeYQ1rEM28 8ldy9gyjGB35j9v8nlOtyLxbpH9sPobvtOMTx/X/3wdYnZ9TxHBFV4KOkxAcFIHeCEKi 0dvNQ2+ygiKEAK7hOpsLRFtaY4NyPqkOaD/k0ZUK9UYYyVYjXPZRR7+PXRy+XclOWjCm dNDB1OELySa+Xq01GMBwx/Wc0wRj2/G2khq6FSqi46PJ4o7GhojgoQZBBlVseacKCrxE Fk9cmBs2sKXJlK8CY7f2xC/y2oVDqoIOkL3MP/+svWm5vTX/7sS4J3AzSxiuUJHB66kf HIGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M7cygNuQv/R1u8CJs+gp7c5R4DnZyamtxh5srkkTrmQ=; b=UdAepvspApNb4df9iKIY2L7/T8lHaGe7u+/Shy09szHFAIkl+g6ptenItk806LNx+R 7/XUXFLEtBiHAZahVGl+slcY5qpracYGNvLSGnghw73TQCYECramKjlJNDjUCD6RbGlB 2v/75gQqUSensNfiYOZ56svs5bKRocAfWg9koAtVZeitZhT+U13aOuS+16tfgvvFhnbx kCUrYSuCMhF2/UlEFfSSapoCjE2kqcPFX4R/7PU6zkVnT3zWqCSbDCNO74Iz4LcrtZ7O dUuPdN5pFt0NboI0uOA4S66wmjvqmhIG2YJgxvbqt2R01KR2P2q3QuCvvmTyo8pCJEh6 g5uQ== X-Gm-Message-State: APjAAAXnERhKAKDbWUW/lG5oiqdkOO3CBNPyXj597DR2Q+2RbokoJNDO xb3aQB3ovui7CT3HxshY//LJncVK9LEPlg== X-Google-Smtp-Source: APXvYqz2QhUSu65jI50uusGpa4vkEFrU9IHf3GO0dlnTCPUZt1TiIXKzG+Yxgmjh/IL9z8id3gEGlQ== X-Received: by 2002:a1c:4c1a:: with SMTP id z26mr24343489wmf.2.1563198138072; Mon, 15 Jul 2019 06:42:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 14:42:06 +0100 Message-Id: <20190715134211.23063-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134211.23063-1-peter.maydell@linaro.org> References: <20190715134211.23063-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::336 Subject: [Qemu-devel] [PULL 05/10] hw/ssi/mss-spi: Avoid crash when reading empty RX FIFO 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Reading the RX_DATA register when the RX_FIFO is empty triggers an abort. This can be easily reproduced: $ qemu-system-arm -M emcraft-sf2 -monitor stdio -S QEMU 4.0.50 monitor - type 'help' for more information (qemu) x 0x40001010 Aborted (core dumped) (gdb) bt #1 0x00007f035874f895 in abort () at /lib64/libc.so.6 #2 0x00005628686591ff in fifo8_pop (fifo=3D0x56286a9a4c68) at util/fifo8= .c:66 #3 0x00005628683e0b8e in fifo32_pop (fifo=3D0x56286a9a4c68) at include/q= emu/fifo32.h:137 #4 0x00005628683e0efb in spi_read (opaque=3D0x56286a9a4850, addr=3D4, si= ze=3D4) at hw/ssi/mss-spi.c:168 #5 0x0000562867f96801 in memory_region_read_accessor (mr=3D0x56286a9a4b6= 0, addr=3D16, value=3D0x7ffeecb0c5c8, size=3D4, shift=3D0, mask=3D429496729= 5, attrs=3D...) at memory.c:439 #6 0x0000562867f96cdb in access_with_adjusted_size (addr=3D16, value=3D0= x7ffeecb0c5c8, size=3D4, access_size_min=3D1, access_size_max=3D4, access_f= n=3D0x562867f967c3 , mr=3D0x56286a9a4b60, attr= s=3D...) at memory.c:569 #7 0x0000562867f99940 in memory_region_dispatch_read1 (mr=3D0x56286a9a4b= 60, addr=3D16, pval=3D0x7ffeecb0c5c8, size=3D4, attrs=3D...) at memory.c:14= 20 #8 0x0000562867f99a08 in memory_region_dispatch_read (mr=3D0x56286a9a4b6= 0, addr=3D16, pval=3D0x7ffeecb0c5c8, size=3D4, attrs=3D...) at memory.c:1447 #9 0x0000562867f38721 in flatview_read_continue (fv=3D0x56286aec6360, ad= dr=3D1073745936, attrs=3D..., buf=3D0x7ffeecb0c7c0 "\340=C7=B0\354\376\177"= , len=3D4, addr1=3D16, l=3D4, mr=3D0x56286a9a4b60) at exec.c:3385 #10 0x0000562867f38874 in flatview_read (fv=3D0x56286aec6360, addr=3D1073= 745936, attrs=3D..., buf=3D0x7ffeecb0c7c0 "\340=C7=B0\354\376\177", len=3D4= ) at exec.c:3423 #11 0x0000562867f388ea in address_space_read_full (as=3D0x56286aa3e890, a= ddr=3D1073745936, attrs=3D..., buf=3D0x7ffeecb0c7c0 "\340=C7=B0\354\376\177= ", len=3D4) at exec.c:3436 #12 0x0000562867f389c5 in address_space_rw (as=3D0x56286aa3e890, addr=3D1= 073745936, attrs=3D..., buf=3D0x7ffeecb0c7c0 "\340=C7=B0\354\376\177", len= =3D4, is_write=3Dfalse) at exec.c:3466 #13 0x0000562867f3bdd7 in cpu_memory_rw_debug (cpu=3D0x56286aa19d00, addr= =3D1073745936, buf=3D0x7ffeecb0c7c0 "\340=C7=B0\354\376\177", len=3D4, is_w= rite=3D0) at exec.c:3976 #14 0x000056286811ed51 in memory_dump (mon=3D0x56286a8c32d0, count=3D1, f= ormat=3D120, wsize=3D4, addr=3D1073745936, is_physical=3D0) at monitor/misc= .c:730 #15 0x000056286811eff1 in hmp_memory_dump (mon=3D0x56286a8c32d0, qdict=3D= 0x56286b15c400) at monitor/misc.c:785 #16 0x00005628684740ee in handle_hmp_command (mon=3D0x56286a8c32d0, cmdli= ne=3D0x56286a8caeb2 "0x40001010") at monitor/hmp.c:1082 From the datasheet "Actel SmartFusion Microcontroller Subsystem User's Guide" Rev.1, Table 13-3 "SPI Register Summary", this register has a reset value of 0. Check the FIFO is not empty before accessing it, else log an error message. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-id: 20190709113715.7761-3-philmd@redhat.com Signed-off-by: Peter Maydell --- hw/ssi/mss-spi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c index 918b1f3e821..4c9da5d2b28 100644 --- a/hw/ssi/mss-spi.c +++ b/hw/ssi/mss-spi.c @@ -165,7 +165,13 @@ spi_read(void *opaque, hwaddr addr, unsigned int size) case R_SPI_RX: s->regs[R_SPI_STATUS] &=3D ~S_RXFIFOFUL; s->regs[R_SPI_STATUS] &=3D ~S_RXCHOVRF; - ret =3D fifo32_pop(&s->rx_fifo); + if (fifo32_is_empty(&s->rx_fifo)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Reading empty RX_FIFO\n", + __func__); + } else { + ret =3D fifo32_pop(&s->rx_fifo); + } if (fifo32_is_empty(&s->rx_fifo)) { s->regs[R_SPI_STATUS] |=3D S_RXFIFOEMP; } --=20 2.20.1 From nobody Tue May 7 23:08:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1563198223; cv=none; d=zoho.com; s=zohoarc; b=CRaWRmjQMLAMfqTT0+ZcREzgYlAwyj+vDcnWAEX3oBxVvukHiPf7z5tk03pFANNqAx1RTrFvBkx1ncd8c//kvwYk6uAj6rrxib5SRZd0E3fhSZi7BbLglW3uOdJ7x9q8wQKrrQXas2qJZWuSfSsu2HAlJekPMPy0c3TmhcU+tP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563198223; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lHOw/lFmFh4DCBqEH/SEFyeXO8oWbfUPsK1BSik9p+k=; b=huUFPByWTAnqoC0eZ+MsSnDPOUcMUWbZLM+JtNsboORHtyaPE9hMVYeaMRiFDEiIuQ5E2rV5QKp7AzzcuSkqD878G4pH+WZMJdQq8u+pjR0+y9RoRLqesrH8ohDz7jMdK4vrO9GSLEElzx9qUM0Ubx1DGntILniaeNZPqJigzBE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563198223238893.0754763700016; Mon, 15 Jul 2019 06:43:43 -0700 (PDT) Received: from localhost ([::1]:38744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1GX-0004bt-Ry for importer@patchew.org; Mon, 15 Jul 2019 09:43:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51786) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1FG-0007sT-VL for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1FF-0006Ap-8r for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:22 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:36202) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn1FF-00069c-2T for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:21 -0400 Received: by mail-wm1-x32c.google.com with SMTP id g67so11155196wme.1 for ; Mon, 15 Jul 2019 06:42:20 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c7sm14221808wro.70.2019.07.15.06.42.18 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 06:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lHOw/lFmFh4DCBqEH/SEFyeXO8oWbfUPsK1BSik9p+k=; b=EyNgZrxGyFWbJv274Z/DHUUe6esAV/mM5X262HZ6Uzw653STIvLUSsyJshnK9MAylp OXkwdXS0AfBgNTST1TSD/of004/rpC+QNaJ0Dt1TpAn9aqB+xu6tYpw80ApiAD3dkxRs MCU1K07ssWn5MTsG97DTr7DN7zRU6HbG98wXXLKHzDZH4rwomxzUjIRTiGDAcOFHTajz XQDfMxLk56zgjjtadbgatETYut880FehZZFSFkcLdAOMkG7oyc2AQDciHoCh+pGT3u/t fhTlIyTsipKFwyQ4VLC4avxKpn1HRBiH2C13ZyLkGrlETdISAYpkT54WsLErWizKPxH0 D2ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lHOw/lFmFh4DCBqEH/SEFyeXO8oWbfUPsK1BSik9p+k=; b=e3v92ymIeRxAkc4VzutcoyBsBxCV6a5uYnprZEIBFyNvrTUHC3b1XUPQPgDV43MW9/ JcJDI2DEvXRRh24LYY1vQGkpUPzuaLgD6WQQ2Fb0yfNjXkACBdJD8XoRz9eG4gaw9Pde Cie706XBYAhUEjviIPL4ci67VVnEql0XvXe8lCbRpyh9AMiPG6GqT9qwS4PxvyYA0gvQ GqdTeptJon7nF1vBQDnln67sC70y7kgCJUINm18tOhKMoLgaZn2jFzXBN6kkOc8bTxpL yA5mmVulvm0S7BXiqIf1iCLK/HGn+M7BLrM2z4ySIiPeZ3NjTnLtPMAQfHFXx51IrZgN Px1A== X-Gm-Message-State: APjAAAViPamRo2IDScnmnU00hxk+zBltsVdbeCRm9TD80YSxwyBI53Mt fF7RI7QLdAXREd67e+f2LHzG3UqKfFk1OA== X-Google-Smtp-Source: APXvYqy2OuV9w/c+f5kAHvBgI2Dh1XMZBPEVkoLPUVzGeen12hcG7lbiWsG1eF1PFLbS5eFhnqXvag== X-Received: by 2002:a1c:c542:: with SMTP id v63mr24181312wmf.97.1563198138969; Mon, 15 Jul 2019 06:42:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 14:42:07 +0100 Message-Id: <20190715134211.23063-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134211.23063-1-peter.maydell@linaro.org> References: <20190715134211.23063-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32c Subject: [Qemu-devel] [PULL 06/10] hw/display/xlnx_dp: Avoid crash when reading empty RX FIFO 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 In the previous commit we fixed a crash when the guest read a register that pop from an empty FIFO. By auditing the repository, we found another similar use with an easy way to reproduce: $ qemu-system-aarch64 -M xlnx-zcu102 -monitor stdio -S QEMU 4.0.50 monitor - type 'help' for more information (qemu) xp/b 0xfd4a0134 Aborted (core dumped) (gdb) bt #0 0x00007f6936dea57f in raise () at /lib64/libc.so.6 #1 0x00007f6936dd4895 in abort () at /lib64/libc.so.6 #2 0x0000561ad32975ec in xlnx_dp_aux_pop_rx_fifo (s=3D0x7f692babee70) at= hw/display/xlnx_dp.c:431 #3 0x0000561ad3297dc0 in xlnx_dp_read (opaque=3D0x7f692babee70, offset= =3D77, size=3D4) at hw/display/xlnx_dp.c:667 #4 0x0000561ad321b896 in memory_region_read_accessor (mr=3D0x7f692babf62= 0, addr=3D308, value=3D0x7ffe05c1db88, size=3D4, shift=3D0, mask=3D42949672= 95, attrs=3D...) at memory.c:439 #5 0x0000561ad321bd70 in access_with_adjusted_size (addr=3D308, value=3D= 0x7ffe05c1db88, size=3D1, access_size_min=3D4, access_size_max=3D4, access_= fn=3D0x561ad321b858 , mr=3D0x7f692babf620, att= rs=3D...) at memory.c:569 #6 0x0000561ad321e9d5 in memory_region_dispatch_read1 (mr=3D0x7f692babf6= 20, addr=3D308, pval=3D0x7ffe05c1db88, size=3D1, attrs=3D...) at memory.c:1= 420 #7 0x0000561ad321ea9d in memory_region_dispatch_read (mr=3D0x7f692babf62= 0, addr=3D308, pval=3D0x7ffe05c1db88, size=3D1, attrs=3D...) at memory.c:14= 47 #8 0x0000561ad31bd742 in flatview_read_continue (fv=3D0x561ad69c04f0, ad= dr=3D4249485620, attrs=3D..., buf=3D0x7ffe05c1dcf0 "\020\335\301\005\376\17= 7", len=3D1, addr1=3D308, l=3D1, mr=3D0x7f692babf620) at exec.c:3385 #9 0x0000561ad31bd895 in flatview_read (fv=3D0x561ad69c04f0, addr=3D4249= 485620, attrs=3D..., buf=3D0x7ffe05c1dcf0 "\020\335\301\005\376\177", len= =3D1) at exec.c:3423 #10 0x0000561ad31bd90b in address_space_read_full (as=3D0x561ad5bb3020, a= ddr=3D4249485620, attrs=3D..., buf=3D0x7ffe05c1dcf0 "\020\335\301\005\376\1= 77", len=3D1) at exec.c:3436 #11 0x0000561ad33b1c42 in address_space_read (len=3D1, buf=3D0x7ffe05c1dc= f0 "\020\335\301\005\376\177", attrs=3D..., addr=3D4249485620, as=3D0x561ad= 5bb3020) at include/exec/memory.h:2131 #12 0x0000561ad33b1c42 in memory_dump (mon=3D0x561ad59c4530, count=3D1, f= ormat=3D120, wsize=3D1, addr=3D4249485620, is_physical=3D1) at monitor/misc= .c:723 #13 0x0000561ad33b1fc1 in hmp_physical_memory_dump (mon=3D0x561ad59c4530,= qdict=3D0x561ad6c6fd00) at monitor/misc.c:795 #14 0x0000561ad37b4a9f in handle_hmp_command (mon=3D0x561ad59c4530, cmdli= ne=3D0x561ad59d0f22 "/b 0x00000000fd4a0134") at monitor/hmp.c:1082 Fix by checking the FIFO is not empty before popping from it. The datasheet is not clear about the reset value of this register, we choose to return '0'. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-id: 20190709113715.7761-4-philmd@redhat.com Signed-off-by: Peter Maydell --- hw/display/xlnx_dp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index cfd4c700b7f..cc5b650df0c 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -427,11 +427,18 @@ static uint8_t xlnx_dp_aux_pop_rx_fifo(XlnxDPState *s) uint8_t ret; =20 if (fifo8_is_empty(&s->rx_fifo)) { - DPRINTF("rx_fifo underflow..\n"); - abort(); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Reading empty RX_FIFO\n", + __func__); + /* + * The datasheet is not clear about the reset value, it seems + * to be unspecified. We choose to return '0'. + */ + ret =3D 0; + } else { + ret =3D fifo8_pop(&s->rx_fifo); + DPRINTF("pop 0x%" PRIX8 " from rx_fifo.\n", ret); } - ret =3D fifo8_pop(&s->rx_fifo); - DPRINTF("pop 0x%" PRIX8 " from rx_fifo.\n", ret); return ret; } =20 --=20 2.20.1 From nobody Tue May 7 23:08:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1563198222; cv=none; d=zoho.com; s=zohoarc; b=djP8aIVjurH9Dit+r8t+QjuOqE8GJBvNYUOg8+UBvfhbSetd1lG4+m9oBDu8eIOANKDjBimFNd50V9vIwtJExsNcucke66gR/pFXLulQ2l3yn/uH7/5AfovxoILWKVl4/tbXM05VOPoUC6F7znKM3Y3nTywAPZ+roMOyLKOe+hU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563198222; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Lkg7H1NRSw1xymZWFmnKrvzweUJjE5TzOTqnyXYm+p0=; b=H2bSTq1qbjVldp9z6e1y+5gtuKkzsIMahPvIT837u8mIf3MdycUTirqPykIKtJtd/7J10s4LyoUammB9CiZHtJVw6SSNzx/CZQoSzqYEOP/SF5LXQva1wbHO5WtxQVt57YfpNHtiu23DheIeLRyWd4KeNYx/4TnrxEhZC7xmZzU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563198222959681.1870779851143; Mon, 15 Jul 2019 06:43:42 -0700 (PDT) Received: from localhost ([::1]:38740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1GU-0004N9-LQ for importer@patchew.org; Mon, 15 Jul 2019 09:43:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51787) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1FG-0007sU-VV for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1FF-0006BH-NU for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:22 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:39297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn1FF-00069z-Gr for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:21 -0400 Received: by mail-wr1-x42f.google.com with SMTP id x4so17141142wrt.6 for ; Mon, 15 Jul 2019 06:42:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c7sm14221808wro.70.2019.07.15.06.42.19 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 06:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Lkg7H1NRSw1xymZWFmnKrvzweUJjE5TzOTqnyXYm+p0=; b=beAAmzYmHgMu4mw9foyEgPO/LTAocGSdXuDkBTbB2NcOTLZuK0k6hnfAFO/+3vdmZy W/kGAg/CktB/772KsVN4pXD9/bQuvTX+gbPMA6HNpyd65sbQ9sQp3UO3yTz/g95DVZXL WKytwXYSPqbogTs0Z0T2wEGKME8nRDL5b6TwYcrdx13pL9HYm2OnUs1Qotq4Oji9FLOL 4QQPomFiGijzU3LEAD9C0PxOhg+X37PTZpITqJxUk/J/rVAjk16ohjGmvxMHt+MOJSgw Sy4j5v98ZnDVpT6wKvgYJZ1OPLc9bBn2jbT/dC5/lLM+7l2yM2QqD3NUR+B4ciM8W9NX LDGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Lkg7H1NRSw1xymZWFmnKrvzweUJjE5TzOTqnyXYm+p0=; b=iSA8T1xkahG1Ht5rFa+UVIxpz123sl2T+X3/jCnLZy590B9ao8avy1KrQBxS9vZUDE kBURyuPr8yC08fSdPXP9ZuauWWPEjy7f+SWuJQxoc3Zw6Jz94DxyObF9dQYe3cZmxOG5 Wh8PS9kHIUFxmbIEAuNOd2VVKq9dZylv6AFeNxa9zZKwUDBAJkZGxOoA8mpsxwLSL5XJ 9CJzfp0ElT684OzCo87KgjqbBo3Jsh6VLfDqCMtubgG5CkPASHV8upwy5ehFUj8RcuLg CfRNC0n7iUN9GLpvfMKfa0j5ov946LaMgp6/y6LRlCuHmJHVfr1Xw+CM5QO0tty2Nivs OIQg== X-Gm-Message-State: APjAAAULJJHYOXOgw3TMrnP1wHQCpTX0swA+7GRnCnn2S3n1ajzsJT6I 8In5KACVFxQGVcqgnEXH2FlNnwOvtte/oQ== X-Google-Smtp-Source: APXvYqyiu+KISngMkfNELdbRmmyVoYuPkMAg+WC4Xcas2ZY1g7OTuHHAX0OkQn2yotys+XdYAOd6ZQ== X-Received: by 2002:adf:f646:: with SMTP id x6mr31177839wrp.18.1563198139863; Mon, 15 Jul 2019 06:42:19 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 14:42:08 +0100 Message-Id: <20190715134211.23063-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134211.23063-1-peter.maydell@linaro.org> References: <20190715134211.23063-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f Subject: [Qemu-devel] [PULL 07/10] hw/arm/virt: Fix non-secure flash mode 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: David Engraf Using the whole 128 MiB flash in non-secure mode is not working because virt_flash_fdt() expects the same address for secure_sysmem and sysmem. This is not correctly handled by caller because it forwards NULL for secure_sysmem in non-secure flash mode. Fixed by using sysmem when secure_sysmem is NULL. Signed-off-by: David Engraf Message-id: 20190712075002.14326-1-david.engraf@sysgo.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 0b5138cb22c..d9496c93634 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1674,7 +1674,7 @@ static void machvirt_init(MachineState *machine) &machine->device_memory->mr); } =20 - virt_flash_fdt(vms, sysmem, secure_sysmem); + virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem); =20 create_gic(vms, pic); =20 --=20 2.20.1 From nobody Tue May 7 23:08:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1563198249; cv=none; d=zoho.com; s=zohoarc; b=PBfn3oIqJm9yUHBINAHkvoh9l+QPLW0soMxSVC2qGJgtN4bXvsI/bedyTpTkPAR+bOCDsWrzAuMqxmA+pLr9B87Xs+odJ2mnOb4YXhPQJUHJVi5nn3mbupnzQmhmJlk3cfvRSYCsKE7S4BWFhUl/0S3mMj5s2LjMUMBR2m++O1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563198249; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=cELbSeZqo/rDUDZMNhqVynDCy8syqeSGDgG78iLpC1o=; b=IxvmK0aiuHy5Vo6JHM4ZjtLO8oG6zt7DjwnDwcbOQqJGz2XWQTThMN+PbmibQPtCYfQLw6Tot4LVtwl2RD8nFl9hKuyiP9YuB1PegMBQlYzGwJb8d75ead5e/gC+ho/VdaaAKzPo9Bk8zt7nvDQSV4G1YCBUIEbfdrP5qYQ6MBo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563198249344653.0827190802759; Mon, 15 Jul 2019 06:44:09 -0700 (PDT) Received: from localhost ([::1]:38760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1Gx-0006m5-Uj for importer@patchew.org; Mon, 15 Jul 2019 09:44:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51834) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1FK-00089d-Nw for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1FI-0006DA-OQ for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:26 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:38023) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn1FG-0006Au-Qz for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:23 -0400 Received: by mail-wr1-x42d.google.com with SMTP id g17so17161809wrr.5 for ; Mon, 15 Jul 2019 06:42:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c7sm14221808wro.70.2019.07.15.06.42.19 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 06:42:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cELbSeZqo/rDUDZMNhqVynDCy8syqeSGDgG78iLpC1o=; b=c9/un+s6r1SxgSTnxw9LI8jd/vUak5Ncqy8ZzgPPVMTB+6kG9lNKxH/cvZDdnZfVwv s/ml3O5hLrvdeBJiLKwJCrQU8FseTx7W8LGCIn6Z/jhIAn9YTkqZjbzMpfivj8FQXD4f ddOyqEAwa1Lxi9wGH/32CogzzefMmD4fAXbnGrtJh1zK1VYnn9WjY+i6/z58bii1eKgL e5QLUps2e4K0GyTttTHwcAzXwKKEYCB2IsTfajWyTdTlCmLViMridjlvMp5ke0wd0KXM ad8jQ5JmyP8zY32nWjJSzFbpEKC1mifz2YWcGKnoBl7YWRiJRwigHM3NQ1dcOMdH3UgC UctA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cELbSeZqo/rDUDZMNhqVynDCy8syqeSGDgG78iLpC1o=; b=TVlTNO+wO81PxaRVpc/78mY1W2k0K2lFeq+jZv2gNh+AMLj0PMOC40y/y/125dYTA/ GlpF4vXQvAjtP4aG7YVAJ4CABBRp3qYi0oxo+0s7zxk6R8roN3bDRADYTMg/wUHMut+X RGfbq+b+f89mSJStguGuzHzfYCIpkWa0fPjP/rkM6qgNeRCGONCrMuvu3dR/ovNzYZJK lDuMfksM3CHzuNJkn1XLm6q9ckKOxDhik3ypWHBp1IRRZugooxKnDK/edEsZ1k/X14ZJ zX6dNzrHTCO/ovLOXqdmnAvthxFfJlfiLiJ9olCKopgJKALvzyiln7QtaHjWprldZ2B7 XcOg== X-Gm-Message-State: APjAAAWXmqcPzuXKHyfNy45sFFjOYcRuSRZHBkVqtUWVRGTWLZA6ITrn V5Br9iQxb6K761aF02zNMICTR7Hp5DBDOA== X-Google-Smtp-Source: APXvYqzHUNPN0IBZE7Z5X8XDvHhKoXZPUNlBDUtTjk0N88n291oTkdOljOJpz4CUXqSXTdWAUaim5w== X-Received: by 2002:a5d:4cca:: with SMTP id c10mr27919650wrt.233.1563198140802; Mon, 15 Jul 2019 06:42:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 14:42:09 +0100 Message-Id: <20190715134211.23063-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134211.23063-1-peter.maydell@linaro.org> References: <20190715134211.23063-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d Subject: [Qemu-devel] [PULL 08/10] pl031: Correctly migrate state when using -rtc clock=host 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The PL031 RTC tracks the difference between the guest RTC and the host RTC using a tick_offset field. For migration, however, we currently always migrate the offset between the guest and the vm_clock, even if the RTC clock is not the same as the vm_clock; this was an attempt to retain migration backwards compatibility. Unfortunately this results in the RTC behaving oddly across a VM state save and restore -- since the VM clock stands still across save-then-restore, regardless of how much real world time has elapsed, the guest RTC ends up out of sync with the host RTC in the restored VM. Fix this by migrating the raw tick_offset. To retain migration compatibility as far as possible, we have a new property migrate-tick-offset; by default this is 'true' and we will migrate the true tick offset in a new subsection; if the incoming data has no subsection we fall back to the old vm_clock-based offset information, so old->new migration compatibility is preserved. For complete new->old migration compatibility, the property is set to 'false' for 4.0 and earlier machine types (this will only affect 'virt-4.0' and below, as none of the other pl031-using machines are versioned). Reported-by: Russell King Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert Message-id: 20190709143912.28905-1-peter.maydell@linaro.org --- include/hw/timer/pl031.h | 2 + hw/core/machine.c | 1 + hw/timer/pl031.c | 92 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 91 insertions(+), 4 deletions(-) diff --git a/include/hw/timer/pl031.h b/include/hw/timer/pl031.h index 8857c24ca5d..8c3f555ee28 100644 --- a/include/hw/timer/pl031.h +++ b/include/hw/timer/pl031.h @@ -33,6 +33,8 @@ typedef struct PL031State { */ uint32_t tick_offset_vmstate; uint32_t tick_offset; + bool tick_offset_migrated; + bool migrate_tick_offset; =20 uint32_t mr; uint32_t lr; diff --git a/hw/core/machine.c b/hw/core/machine.c index c4ead160104..c58a8e594ef 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -35,6 +35,7 @@ GlobalProperty hw_compat_4_0[] =3D { { "virtio-gpu-pci", "edid", "false" }, { "virtio-device", "use-started", "false" }, { "virtio-balloon-device", "qemu-4-0-config-size", "true" }, + { "pl031", "migrate-tick-offset", "false" }, }; const size_t hw_compat_4_0_len =3D G_N_ELEMENTS(hw_compat_4_0); =20 diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c index 3378084f4a8..1a7e2ee06b3 100644 --- a/hw/timer/pl031.c +++ b/hw/timer/pl031.c @@ -199,29 +199,94 @@ static int pl031_pre_save(void *opaque) { PL031State *s =3D opaque; =20 - /* tick_offset is base_time - rtc_clock base time. Instead, we want to - * store the base time relative to the QEMU_CLOCK_VIRTUAL for backward= s-compatibility. */ + /* + * The PL031 device model code uses the tick_offset field, which is + * the offset between what the guest RTC should read and what the + * QEMU rtc_clock reads: + * guest_rtc =3D rtc_clock + tick_offset + * and so + * tick_offset =3D guest_rtc - rtc_clock + * + * We want to migrate this offset, which sounds straightforward. + * Unfortunately older versions of QEMU migrated a conversion of this + * offset into an offset from the vm_clock. (This was in turn an + * attempt to be compatible with even older QEMU versions, but it + * has incorrect behaviour if the rtc_clock is not the same as the + * vm_clock.) So we put the actual tick_offset into a migration + * subsection, and the backwards-compatible time-relative-to-vm_clock + * in the main migration state. + * + * Calculate base time relative to QEMU_CLOCK_VIRTUAL: + */ int64_t delta =3D qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEM= U_CLOCK_VIRTUAL); s->tick_offset_vmstate =3D s->tick_offset + delta / NANOSECONDS_PER_SE= COND; =20 return 0; } =20 +static int pl031_pre_load(void *opaque) +{ + PL031State *s =3D opaque; + + s->tick_offset_migrated =3D false; + return 0; +} + static int pl031_post_load(void *opaque, int version_id) { PL031State *s =3D opaque; =20 - int64_t delta =3D qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEM= U_CLOCK_VIRTUAL); - s->tick_offset =3D s->tick_offset_vmstate - delta / NANOSECONDS_PER_SE= COND; + /* + * If we got the tick_offset subsection, then we can just use + * the value in that. Otherwise the source is an older QEMU and + * has given us the offset from the vm_clock; convert it back to + * an offset from the rtc_clock. This will cause time to incorrectly + * go backwards compared to the host RTC, but this is unavoidable. + */ + + if (!s->tick_offset_migrated) { + int64_t delta =3D qemu_clock_get_ns(rtc_clock) - + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + s->tick_offset =3D s->tick_offset_vmstate - + delta / NANOSECONDS_PER_SECOND; + } pl031_set_alarm(s); return 0; } =20 +static int pl031_tick_offset_post_load(void *opaque, int version_id) +{ + PL031State *s =3D opaque; + + s->tick_offset_migrated =3D true; + return 0; +} + +static bool pl031_tick_offset_needed(void *opaque) +{ + PL031State *s =3D opaque; + + return s->migrate_tick_offset; +} + +static const VMStateDescription vmstate_pl031_tick_offset =3D { + .name =3D "pl031/tick-offset", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D pl031_tick_offset_needed, + .post_load =3D pl031_tick_offset_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(tick_offset, PL031State), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_pl031 =3D { .name =3D "pl031", .version_id =3D 1, .minimum_version_id =3D 1, .pre_save =3D pl031_pre_save, + .pre_load =3D pl031_pre_load, .post_load =3D pl031_post_load, .fields =3D (VMStateField[]) { VMSTATE_UINT32(tick_offset_vmstate, PL031State), @@ -231,14 +296,33 @@ static const VMStateDescription vmstate_pl031 =3D { VMSTATE_UINT32(im, PL031State), VMSTATE_UINT32(is, PL031State), VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription*[]) { + &vmstate_pl031_tick_offset, + NULL } }; =20 +static Property pl031_properties[] =3D { + /* + * True to correctly migrate the tick offset of the RTC. False to + * obtain backward migration compatibility with older QEMU versions, + * at the expense of the guest RTC going backwards compared with the + * host RTC when the VM is saved/restored if using -rtc host. + * (Even if set to 'true' older QEMU can migrate forward to newer QEMU; + * 'false' also permits newer QEMU to migrate to older QEMU.) + */ + DEFINE_PROP_BOOL("migrate-tick-offset", + PL031State, migrate_tick_offset, true), + DEFINE_PROP_END_OF_LIST() +}; + static void pl031_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->vmsd =3D &vmstate_pl031; + dc->props =3D pl031_properties; } =20 static const TypeInfo pl031_info =3D { --=20 2.20.1 From nobody Tue May 7 23:08:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1563198257; cv=none; d=zoho.com; s=zohoarc; b=c6wDyNmNwgH+JxUys7ozKcQZD2DcNT3hUYT9y+NVZYPhb+7SDA8eMtxxqPDTDleh17JYOFXUXbr1hu63/IxuN3p/7NODMKCZPk47msb1DRaA/BKGuOkwf3t3TLDFF4ZsZGugsrl+rLP0AsLfdvuGoGNgwKXNavRK6GwnddfAh+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563198257; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=kmd44QPB5fQioinpnyOTPTkf7ReufwKIl1vLPJ0oHiI=; b=Yc/eoedGCTc1nco4b4YGaPTQqDerGTvssQt5rR+hFCkEiNcMaFn+5LL8UH3gdQdX9mpkIU/B3WDZ30cvF3bSzFSVW3rrI+POthjBtIG85ITEKUokA6Aub58jwVFeRrycqaJCegeeW9QvMtMsgdiYsLGzOhPnNBaONDTmIuyGaGs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563198257392334.62125077666246; Mon, 15 Jul 2019 06:44:17 -0700 (PDT) Received: from localhost ([::1]:38762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1H6-0007QI-Ak for importer@patchew.org; Mon, 15 Jul 2019 09:44:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51830) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1FK-00086m-1t for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1FI-0006D5-O9 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:25 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:32903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn1FG-0006Bd-Rh for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:23 -0400 Received: by mail-wm1-x342.google.com with SMTP id h19so14355384wme.0 for ; Mon, 15 Jul 2019 06:42:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c7sm14221808wro.70.2019.07.15.06.42.20 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 06:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kmd44QPB5fQioinpnyOTPTkf7ReufwKIl1vLPJ0oHiI=; b=N03UZhwWttVqwYCo8jdV55LfKwpaawjnoneiS3Doxwu5Ll+hLGfgV0ddQ0lAKE6Tw0 kR0WiaE+UgxrBvmAjbL9349+Ld6KyFWzoAblO2rxVuii1YUOAUmoWhfilOG1UjjySmc2 8Gj5PkZAbjY6VouB6f09z5jXfHhIwlXwtFxhiQF3LRKHR/V4vRGF8h6p8uI0vSYk2RvY Cchq+L6L5sesnaRZLRKbRXRWYQb4l73E0GlTox0m3/Byf4Ek5VrM86pL2qY1mIEDpdu0 GMpKhKhQTMw2PmZP/OFlyz9T7grdhc+QNiIbBeIl1BJ6iLVST4KrJWeEUW9jGdYSklFx 57TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kmd44QPB5fQioinpnyOTPTkf7ReufwKIl1vLPJ0oHiI=; b=aoLwKVh5IFEi7s6dw7hsrhfiQrSfGYHcykAbotR7SuHdLlIdN2/E3nXMfXEadv02WF C+Vrhas72KuRBG57rTqu9J1jnHfC8ac2+HZ69Pleugl3blIwPnsoj4IyfeYZRF/KX9+/ KtTlaZtmT0seoyWV21LHQGV/26diJA20DuksNIuVRaCIS4SN6c5OuH/NgUc6ELA8Kt5C T8aoISIEfqeSkslo4Yi9XRHWg/gdwjIh0bQUHAbWYAxtJNlTOpKTaWF4aU9llfH7qyYj rNpBsgZPTo0OaeX8G3QYg5NCi3HmYMT7kZzzCN4D0in46IlPU2FjxhXtF08J9LrAodc5 RwIg== X-Gm-Message-State: APjAAAX0Ip8QKrjSQHEFYRBMue7nD/o/ruoZf6bN4i8GvyKdXS13/5UI JbfQb3GFEHP7kuSgdoPLLZ/CGoMmyNdx6g== X-Google-Smtp-Source: APXvYqyoNM/de+xUoMoBH2YEFzEJzgeA3CZEjEq3Xwec5F00Bqle3ETqq9GUfZNE6m8eicvFh0yLDQ== X-Received: by 2002:a05:600c:da:: with SMTP id u26mr24039839wmm.108.1563198141615; Mon, 15 Jul 2019 06:42:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 14:42:10 +0100 Message-Id: <20190715134211.23063-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134211.23063-1-peter.maydell@linaro.org> References: <20190715134211.23063-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PULL 09/10] target/arm: Set VFP-related MVFR0 fields for arm926 and arm1026 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The ARMv5 architecture didn't specify detailed per-feature ID registers. Now that we're using the MVFR0 register fields to gate the existence of VFP instructions, we need to set up the correct values in the cpu->isar structure so that we still provide an FPU to the guest. This fixes a regression in the arm926 and arm1026 CPUs, which are the only ones that both have VFP and are ARMv5 or earlier. This regression was introduced by the VFP refactoring, and more specifically by commits 1120827fa182f0e76 and 266bd25c485597c, which accidentally disabled VFP short-vector support and double-precision support on these CPUs. Fixes: 1120827fa182f0e Fixes: 266bd25c485597c Fixes: https://bugs.launchpad.net/qemu/+bug/1836192 Reported-by: Christophe Lyon Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Tested-by: Christophe Lyon Message-id: 20190711131241.22231-1-peter.maydell@linaro.org --- target/arm/cpu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ad164a773b2..1959467fdc8 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1666,6 +1666,12 @@ static void arm926_initfn(Object *obj) * set the field to indicate Jazelle support within QEMU. */ cpu->isar.id_isar1 =3D FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELL= E, 1); + /* + * Similarly, we need to set MVFR0 fields to enable double precision + * and short vector support even though ARMv5 doesn't have this regist= er. + */ + cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); + cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); } =20 static void arm946_initfn(Object *obj) @@ -1702,6 +1708,12 @@ static void arm1026_initfn(Object *obj) * set the field to indicate Jazelle support within QEMU. */ cpu->isar.id_isar1 =3D FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELL= E, 1); + /* + * Similarly, we need to set MVFR0 fields to enable double precision + * and short vector support even though ARMv5 doesn't have this regist= er. + */ + cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); + cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); =20 { /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0= ,2 */ --=20 2.20.1 From nobody Tue May 7 23:08:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1563198258; cv=none; d=zoho.com; s=zohoarc; b=iol3klEt5BuYdzlF4pnLey0+nQ6DYGEQGCkRZifFILCkkOz9y3E839z//KsYps+2TcK+gHf7H1o4h2+hOGxybMy+on08CRYXYSk4W96iYDoAvC9k/0c4+BDhxNV816wDTNZUWNsgKsGqNEz3lRcSf1MG0zb3Lv2vqCz1uVNTxcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563198258; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=RbzdNTC0vW9Lf4ZRZ1X4p6Xxj5ih0UlUuNAgV7FoLIU=; b=RjfrIa3ck7B5KmLpngyDYyYuiKWWVjC0RABfJ2A9j7KVI4R+todApQUNpaIYU4YQucCBn42mr4EXUtyCkJ3YKcVfZmKiq9RvBB3PZ9G2VKsWyind+e3z4MyMNsOTMpRW7e4iPTW3SMVCveTusjY4dUKMzs6v8OFEBudk61faLTk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563198258331781.2383885389575; Mon, 15 Jul 2019 06:44:18 -0700 (PDT) Received: from localhost ([::1]:38764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1H6-0007TJ-Qz for importer@patchew.org; Mon, 15 Jul 2019 09:44:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51835) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn1FK-00089k-N2 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn1FI-0006DK-Uk for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:26 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:46350) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn1FI-0006CL-O1 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 09:42:24 -0400 Received: by mail-wr1-x443.google.com with SMTP id z1so17123348wru.13 for ; Mon, 15 Jul 2019 06:42:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c7sm14221808wro.70.2019.07.15.06.42.21 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 15 Jul 2019 06:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RbzdNTC0vW9Lf4ZRZ1X4p6Xxj5ih0UlUuNAgV7FoLIU=; b=FXrfPeEpNgg3OKHKq5K0dTwaVYN06LJ2be1JoD3H6ymf09RbfoSkIAF4SjS/ohrvTT dhVWtwFtLUHfzGPorgU+o37FDXuZ3s/9j0jadvl7+h4cj/0MIl+137i7+dOf/czPLr7C zMtDoR3tiN6W9nBBcdRJsD2uzR7XdXWvFieC1jVvNm8dcRXR2WJIeuS94UB2siYq4dEm VpeJUfnbGJI6lTDgHukYpMk2sgV3w6JGnyxvSjD9zupzT3KfaEiQQo6y0PGwVBrvo/Y0 wkulsYpFgKbb71IWLt2pym8JnavCXK4AnKtoo6SIzI4AnCrdNntcHeMTPoZ5DVo0SaTC uPdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RbzdNTC0vW9Lf4ZRZ1X4p6Xxj5ih0UlUuNAgV7FoLIU=; b=MIaK1AFPGjykyBqYp00J2z6LIrLlWPYdIwwqRuTE41trB6TcntoYGS9e5YVFY6o4Jw sqmKLyCbLlu77iUiLSQ4uyvBy2foNf9d5l1ACZnu4KsdVv53J3JsaS2yEiBaVqiTr9Da 5W7durcN0wKDduy1LV1gSkiCytwcV3B5DVsp4nSQQj3+uVh2BU5Mrga8dmQ04lJRFPii t7uPJOtkOpfEPYxuFGX0eeqgAVJgJWB/KfRKH6Neuz7/pmkKRTXJRZhy89lapa0zowqR MS4ErMuHEKHnkXhZyhMtfn1RTV4Alw3ff82Phfdv3U7HmZNAlLqO8BuGTCb8T154o9+Q j/MA== X-Gm-Message-State: APjAAAXyotQW0FmXSYyB+TpJorS9pVlAPZYIM7U3mrYHhyeVAn3ru91e /gJh2lJl/KfBHReZIZD/wwRSnls8KpQSNg== X-Google-Smtp-Source: APXvYqwswnLhQSGrKgjkrZ1xrsv24Pw//8wKuAgIoxJEVedlAogpgFp74xRzb5djqivsNpg/HgPQqQ== X-Received: by 2002:a5d:6b07:: with SMTP id v7mr29455852wrw.169.1563198142518; Mon, 15 Jul 2019 06:42:22 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 14:42:11 +0100 Message-Id: <20190715134211.23063-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715134211.23063-1-peter.maydell@linaro.org> References: <20190715134211.23063-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 10/10] target/arm: NS BusFault on vector table fetch escalates to NS HardFault 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In the M-profile architecture, when we do a vector table fetch and it fails, we need to report a HardFault. Whether this is a Secure HF or a NonSecure HF depends on several things. If AIRCR.BFHFNMINS is 0 then HF is always Secure, because there is no NonSecure HardFault. Otherwise, the answer depends on whether the 'underlying exception' (MemManage, BusFault, SecureFault) targets Secure or NonSecure. (In the pseudocode, this is handled in the Vector() function: the final exc.isSecure is calculated by looking at the exc.isSecure from the exception returned from the memory access, not the isSecure input argument.) We weren't doing this correctly, because we were looking at the target security domain of the exception we were trying to load the vector table entry for. This produces errors of two kinds: * a load from the NS vector table which hits the "NS access to S memory" SecureFault should end up as a Secure HardFault, but we were raising an NS HardFault * a load from the S vector table which causes a BusFault should raise an NS HardFault if BFHFNMINS =3D=3D 1 (because in that case all BusFaults are NonSecure), but we were raising a Secure HardFault Correct the logic. We also fix a comment error where we claimed that we might be escalating MemManage to HardFault, and forgot about SecureFault. (Vector loads can never hit MPU access faults, because they're always aligned and always use the default address map.) Signed-off-by: Peter Maydell Message-id: 20190705094823.28905-1-peter.maydell@linaro.org --- target/arm/m_helper.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c index 1867435db7d..84609f446e6 100644 --- a/target/arm/m_helper.c +++ b/target/arm/m_helper.c @@ -624,7 +624,11 @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, = bool targets_secure, if (sattrs.ns) { attrs.secure =3D false; } else if (!targets_secure) { - /* NS access to S memory */ + /* + * NS access to S memory: the underlying exception which we es= calate + * to HardFault is SecureFault, which always targets Secure. + */ + exc_secure =3D true; goto load_fail; } } @@ -632,6 +636,11 @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, = bool targets_secure, vector_entry =3D address_space_ldl(arm_addressspace(cs, attrs), addr, attrs, &result); if (result !=3D MEMTX_OK) { + /* + * Underlying exception is BusFault: its target security state + * depends on BFHFNMINS. + */ + exc_secure =3D !(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK); goto load_fail; } *pvec =3D vector_entry; @@ -641,13 +650,17 @@ load_fail: /* * All vector table fetch fails are reported as HardFault, with * HFSR.VECTTBL and .FORCED set. (FORCED is set because - * technically the underlying exception is a MemManage or BusFault + * technically the underlying exception is a SecureFault or BusFault * that is escalated to HardFault.) This is a terminal exception, * so we will either take the HardFault immediately or else enter * lockup (the latter case is handled in armv7m_nvic_set_pending_deriv= ed()). + * The HardFault is Secure if BFHFNMINS is 0 (meaning that all HFs are + * secure); otherwise it targets the same security state as the + * underlying exception. */ - exc_secure =3D targets_secure || - !(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK); + if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { + exc_secure =3D true; + } env->v7m.hfsr |=3D R_V7M_HFSR_VECTTBL_MASK | R_V7M_HFSR_FORCED_MASK; armv7m_nvic_set_pending_derived(env->nvic, ARMV7M_EXCP_HARD, exc_secur= e); return false; --=20 2.20.1