From patchwork Fri Dec 14 14:41:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013562 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="I3uTpEnU"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYF631YRz9s3q for ; Sat, 15 Dec 2018 01:43:06 +1100 (AEDT) Received: from localhost ([::1]:33876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXogB-0008NS-Vx for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:43:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofW-0008MQ-2v for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofT-0004Bk-QL for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:22 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:42025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofT-0004BD-JO for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:19 -0500 Received: by mail-wr1-x441.google.com with SMTP id q18so5664870wrx.9 for ; Fri, 14 Dec 2018 06:42:19 -0800 (PST) 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=oxz9ienX2lutC4PSsV7HPz8tmpXRN88PsyGbwYxH8OQ=; b=I3uTpEnUHM9ErAOnPVeFT58l1Ca2mKe6LOBVWwyu658QGYSW3W+VTBvkfy/zddTA0/ RCZqIz+rvUIq+wn84b/oKy7wlfm3cT2GLks4Vy8i2BtkIHrgAcWobbrOAIbcmXNU/og0 3HTtnTvQ/9nR1+J5ag2vP67GQBq09HzynTIH0= 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=oxz9ienX2lutC4PSsV7HPz8tmpXRN88PsyGbwYxH8OQ=; b=jdKq4NfMo/VtsGuEgOmZU1DJcgHjybBe2ZDTDT7gvnoheGs+I8vcCXBqFe2wZ0cA7t vqGKX60ZGMk8fmADJ0IxRi2T/11pwmgDAuMj6IAkLFvi6H74unN9Gu5TIbG62cDsJGMn Pp+oX08Ny47tNEZQQL7sO8wFA4ZoPtA/XRbcl+XUrm8r5aaX/vfXSqE/HItYyvq+yiQe JjHLBKUrKX2pRTNdGuwSpMJk2SY3g6sA7EVcWlWhzRW8cAeeA8F7j1mIAf50LMgGkMO2 iXOZ/fntcQLRes7LOlkfFN2sdsCZJen5+Gbert1Qrj1gk/dy+4t1xGQmcgzmHJ+o/Ua3 FEJg== X-Gm-Message-State: AA+aEWbdiDo9r7O4J/eBsT8haK/XR4tAaP88pP/jFA4UmN+pCsuNeGQ9 YVzuZ5ODRwyAwp6XaSwekOy0arkCG4I= X-Google-Smtp-Source: AFSGD/Wgs6rrJE0qXpm9lAbRrmoBmiMZwlWQChkdhFnGVGZK8TDJwlCIparMQpPNyOwRnjycQG5iLw== X-Received: by 2002:adf:c452:: with SMTP id a18mr2894748wrg.145.1544798538353; Fri, 14 Dec 2018 06:42:18 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:17 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:41:53 +0000 Message-Id: <20181214144214.1260-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 01/22] scripts/checkpatch.pl: Enforce multiline comment syntax X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We now require Linux-kernel-style multiline comments: /* * line one * line two */ Enforce this in checkpatch.pl, by backporting the relevant parts of the Linux kernel's checkpatch.pl. (The only changes needed are that Linux's checkpatch.pl WARN() function takes an extra argument that ours does not, and the kernel has a special case for networking code we don't want.)" The kernel's checkpatch does not enforce "leading /* on a line of its own, so that part is unique to QEMU's checkpatch. Sample warning output: WARNING: Block comments use a leading /* on a separate line #34: FILE: hw/intc/arm_gicv3_common.c:39: + /* Older versions of QEMU had a bug in the handling of state save/restore Signed-off-by: Peter Maydell Acked-by: Thomas Huth Reviewed-by: Markus Armbruster --- scripts/checkpatch.pl | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index a892a6cc7c3..18e16b79dfc 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1569,6 +1569,54 @@ sub process { # check we are in a valid C source file if not then ignore this hunk next if ($realfile !~ /\.(h|c|cpp)$/); +# Block comment styles + + # Block comments use /* on a line of its own + if ($rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/ + $rawline =~ m@^\+.*/\*\*?[ \t]*.+[ \t]*$@) { # /* or /** non-blank + WARN("Block comments use a leading /* on a separate line\n" . $herecurr); + } + +# Block comments use * on subsequent lines + if ($prevline =~ /$;[ \t]*$/ && #ends in comment + $prevrawline =~ /^\+.*?\/\*/ && #starting /* + $prevrawline !~ /\*\/[ \t]*$/ && #no trailing */ + $rawline =~ /^\+/ && #line is new + $rawline !~ /^\+[ \t]*\*/) { #no leading * + WARN("Block comments use * on subsequent lines\n" . $hereprev); + } + +# Block comments use */ on trailing lines + if ($rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */ + $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/ + $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/ + $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { #non blank */ + WARN("Block comments use a trailing */ on a separate line\n" . $herecurr); + } + +# Block comment * alignment + if ($prevline =~ /$;[ \t]*$/ && #ends in comment + $line =~ /^\+[ \t]*$;/ && #leading comment + $rawline =~ /^\+[ \t]*\*/ && #leading * + (($prevrawline =~ /^\+.*?\/\*/ && #leading /* + $prevrawline !~ /\*\/[ \t]*$/) || #no trailing */ + $prevrawline =~ /^\+[ \t]*\*/)) { #leading * + my $oldindent; + $prevrawline =~ m@^\+([ \t]*/?)\*@; + if (defined($1)) { + $oldindent = expand_tabs($1); + } else { + $prevrawline =~ m@^\+(.*/?)\*@; + $oldindent = expand_tabs($1); + } + $rawline =~ m@^\+([ \t]*)\*@; + my $newindent = $1; + $newindent = expand_tabs($newindent); + if (length($oldindent) ne length($newindent)) { + WARN("Block comments should align the * on each line\n" . $hereprev); + } + } + # Check for potential 'bare' types my ($stat, $cond, $line_nr_next, $remain_next, $off_next, $realline_next); From patchwork Fri Dec 14 14:41:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jYnOZ9KA"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYF35pBWz9s3q for ; Sat, 15 Dec 2018 01:43:03 +1100 (AEDT) Received: from localhost ([::1]:33874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXog9-0008Md-CA for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:43:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofW-0008MP-2t for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofV-0004Dy-6l for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:22 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:39393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofV-0004Bz-0O for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:21 -0500 Received: by mail-wm1-x335.google.com with SMTP id f81so6003055wmd.4 for ; Fri, 14 Dec 2018 06:42:20 -0800 (PST) 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=mC4JRVd1w8DwNaQrJp6yqmiKHOwVJV8M2MiNdYPvknE=; b=jYnOZ9KAWAvFuEn1OoMQKtbk9S1bebXewF7tV5XcaVNpw3fUQ9ycVTmMbF3mKP4Rbb mC4HnDQDdmfMzsBBYq1IlsUPwVbKkCqPmtnemZZwffTmgATmaUV4D3hBeq/pgKil31ox fE4IU1DBuWSLMi1x+xP6n5jonhrBSbom7GYVA= 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=mC4JRVd1w8DwNaQrJp6yqmiKHOwVJV8M2MiNdYPvknE=; b=He7MKP1+LXGOf+81gLrJIDFoABlzUODNdwlxZTJs9ocYMSjPyABsHspnsosMvjmXdo XuZBEvP9vYEvJyoegUAu1bbyg+JWnIOe6fIDlmfssSp16Ph+yYCKipZV0jq+Xm1nw8OZ 65yRGZDRy0CiV5btVY8I7B3t0WXqFU9Faz8isg3cZgTOuLMpcZf4nxksiUL2qKWR3D6B s9XAYWbS3RoKBst5mzyA875qubxQRhvluulM7437UWtnCLWVmnGGduSftxv2tX3nh8/q iFbU4C1RsxtttIYa24uLk5rlwX1WVR/AbXEAFNcqyL1t2e+MFPjGK1ketYAKU0ysL6dD lTeg== X-Gm-Message-State: AA+aEWYD+iF+nXVXKQGH7+jHzI4pe8HRdHxY6dkjpetxH4KnwoKMFTDE ym2082pp6DNkRtkSoCTu6F6mjOPzKUo= X-Google-Smtp-Source: AFSGD/W3jXcEQYYzO0ykxnArtrHlopWNh6i5AU668JmdpsEM1uX28JyfahkjJzLHrlf8snpO+J1Liw== X-Received: by 2002:a1c:9cce:: with SMTP id f197mr3454082wme.135.1544798539704; Fri, 14 Dec 2018 06:42:19 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:19 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:41:54 +0000 Message-Id: <20181214144214.1260-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 Subject: [Qemu-devel] [PULL 02/22] exec.c: Rename cpu_physical_memory_write_rom_internal() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Rename cpu_physical_memory_write_rom_internal() to address_space_write_rom_internal(), and make it take MemTxAttrs and return a MemTxResult. This brings its API into line with address_space_write(). This is an internal function to exec.c; fixing its API will allow us to change the global function cpu_physical_memory_write_rom(). Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Acked-by: Michael S. Tsirkin Message-id: 20181122133507.30950-2-peter.maydell@linaro.org --- exec.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/exec.c b/exec.c index bb6170dbffe..92679508ba3 100644 --- a/exec.c +++ b/exec.c @@ -3388,8 +3388,12 @@ enum write_rom_type { FLUSH_CACHE, }; -static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as, - hwaddr addr, const uint8_t *buf, int len, enum write_rom_type type) +static inline MemTxResult address_space_write_rom_internal(AddressSpace *as, + hwaddr addr, + MemTxAttrs attrs, + const uint8_t *buf, + int len, + enum write_rom_type type) { hwaddr l; uint8_t *ptr; @@ -3399,8 +3403,7 @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as, rcu_read_lock(); while (len > 0) { l = len; - mr = address_space_translate(as, addr, &addr1, &l, true, - MEMTXATTRS_UNSPECIFIED); + mr = address_space_translate(as, addr, &addr1, &l, true, attrs); if (!(memory_region_is_ram(mr) || memory_region_is_romd(mr))) { @@ -3423,13 +3426,15 @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as, addr += l; } rcu_read_unlock(); + return MEMTX_OK; } /* used for ROM loading : can write in RAM and ROM */ void cpu_physical_memory_write_rom(AddressSpace *as, hwaddr addr, const uint8_t *buf, int len) { - cpu_physical_memory_write_rom_internal(as, addr, buf, len, WRITE_DATA); + address_space_write_rom_internal(as, addr, MEMTXATTRS_UNSPECIFIED, + buf, len, WRITE_DATA); } void cpu_flush_icache_range(hwaddr start, int len) @@ -3444,8 +3449,9 @@ void cpu_flush_icache_range(hwaddr start, int len) return; } - cpu_physical_memory_write_rom_internal(&address_space_memory, - start, NULL, len, FLUSH_CACHE); + address_space_write_rom_internal(&address_space_memory, + start, MEMTXATTRS_UNSPECIFIED, + NULL, len, FLUSH_CACHE); } typedef struct { From patchwork Fri Dec 14 14:41:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013566 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="CfwOtjSx"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYJG2FB3z9sB5 for ; Sat, 15 Dec 2018 01:45:50 +1100 (AEDT) Received: from localhost ([::1]:33887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXoip-0003GE-QB for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:45:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofX-0008Me-Rx for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofW-0004GQ-EG for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:23 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:36477) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofW-0004Eq-74 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:22 -0500 Received: by mail-wm1-x335.google.com with SMTP id a18so6060893wmj.1 for ; Fri, 14 Dec 2018 06:42:22 -0800 (PST) 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=sEd4o/P6TtT/xiZnlj1YU+bU4hPJjApnlkUfuGsu6eo=; b=CfwOtjSxquUK56PfnXmyKbdcdRM+W1jsGCkciDwTcQPIaePyg06obFjh/a1oa3d/Hz 3VhSEC0Zanm+YEfrKnpvM80FpY6oG5u0eHlgSIeaYhMoTQAKFhs9crzyOdoLywZWQCGf z4KuUmZvbuVWXukfgM7fndlGlPtf09wpfCak4= 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=sEd4o/P6TtT/xiZnlj1YU+bU4hPJjApnlkUfuGsu6eo=; b=cmWXqSD1TSdvIqOmOjKQX5zNDRngzrRekdraTZzMnOaPwUjiHSdMdMcZ61kXafVtP1 3VRUJkVIpqOi3ehm9EXBY34cyx7JBNfK5hn3Nt5K2DaFpz/Ys9N/tfGFyh7Q6Jakc42c T/bdzZFl4zDWi7CK7iPPvf293XIj9k71eMhG7kiCOS3a8bNhasoXcCjw6Inw4lTu8mF2 gRLS7WM64EpcYBBnGmoD9+/0/LU/6F8Z+aqSXOOa83421DcNj+ZrMI6hXqtRMnmcDh+2 M/DlSbZUFeCqhyos2TO6v8tySpctu9jrpfDrDvL//VhDPRHG1nhf9e2CTHRoPEoR/Dlt 1BPg== X-Gm-Message-State: AA+aEWaXo8BHBYmGyJh2LAJYsJf9qd8sIE9SieIS7vpjC1bn/xRpQASX nqwQwR9skk3usSFjF4mIS7vKVsXu6E8= X-Google-Smtp-Source: AFSGD/WtehE1h1taZYALAhNuENd/lz0u9rRvnce7bKNP2EuCVuZZGm7TsR8e8uWTAzXFK1WNRL7Rfg== X-Received: by 2002:a1c:7ec4:: with SMTP id z187mr3434582wmc.43.1544798540879; Fri, 14 Dec 2018 06:42:20 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:20 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:41:55 +0000 Message-Id: <20181214144214.1260-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 Subject: [Qemu-devel] [PULL 03/22] Rename cpu_physical_memory_write_rom() to address_space_write_rom() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The API of cpu_physical_memory_write_rom() is odd, because it takes an AddressSpace, unlike all the other cpu_physical_memory_* access functions. Rename it to address_space_write_rom(), and bring its API into line with address_space_write(). Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Acked-by: Michael S. Tsirkin Message-id: 20181122133507.30950-3-peter.maydell@linaro.org --- include/exec/cpu-common.h | 2 -- include/exec/memory.h | 26 ++++++++++++++++++++++++++ exec.c | 14 ++++++++------ hw/core/loader.c | 4 ++-- hw/intc/apic.c | 7 ++++--- hw/misc/tz-mpc.c | 2 +- hw/sparc/sun4m.c | 5 +++-- docs/devel/loads-stores.rst | 35 ++++++++++++++++------------------- 8 files changed, 60 insertions(+), 35 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 18b40d6145c..2ad2d6d86bb 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -111,8 +111,6 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr); */ void qemu_flush_coalesced_mmio_buffer(void); -void cpu_physical_memory_write_rom(AddressSpace *as, hwaddr addr, - const uint8_t *buf, int len); void cpu_flush_icache_range(hwaddr start, int len); extern struct MemoryRegion io_mem_rom; diff --git a/include/exec/memory.h b/include/exec/memory.h index 8e61450de32..ffd23ed8d8d 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1792,6 +1792,32 @@ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, const uint8_t *buf, int len); +/** + * address_space_write_rom: write to address space, including ROM. + * + * This function writes to the specified address space, but will + * write data to both ROM and RAM. This is used for non-guest + * writes like writes from the gdb debug stub or initial loading + * of ROM contents. + * + * Note that portions of the write which attempt to write data to + * a device will be silently ignored -- only real RAM and ROM will + * be written to. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed (eg unassigned memory, device rejected the transaction, + * IOMMU fault). + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @attrs: memory transaction attributes + * @buf: buffer with the data transferred + * @len: the number of bytes to write + */ +MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, + const uint8_t *buf, int len); + /* address_space_ld*: load from an address space * address_space_st*: store to an address space * diff --git a/exec.c b/exec.c index 92679508ba3..6e875f0640a 100644 --- a/exec.c +++ b/exec.c @@ -3430,11 +3430,12 @@ static inline MemTxResult address_space_write_rom_internal(AddressSpace *as, } /* used for ROM loading : can write in RAM and ROM */ -void cpu_physical_memory_write_rom(AddressSpace *as, hwaddr addr, - const uint8_t *buf, int len) +MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, + const uint8_t *buf, int len) { - address_space_write_rom_internal(as, addr, MEMTXATTRS_UNSPECIFIED, - buf, len, WRITE_DATA); + return address_space_write_rom_internal(as, addr, attrs, + buf, len, WRITE_DATA); } void cpu_flush_icache_range(hwaddr start, int len) @@ -3879,8 +3880,9 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, l = len; phys_addr += (addr & ~TARGET_PAGE_MASK); if (is_write) { - cpu_physical_memory_write_rom(cpu->cpu_ases[asidx].as, - phys_addr, buf, l); + address_space_write_rom(cpu->cpu_ases[asidx].as, phys_addr, + MEMTXATTRS_UNSPECIFIED, + buf, l); } else { address_space_rw(cpu->cpu_ases[asidx].as, phys_addr, MEMTXATTRS_UNSPECIFIED, diff --git a/hw/core/loader.c b/hw/core/loader.c index aa0b3fc8679..66a616608af 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -1103,8 +1103,8 @@ static void rom_reset(void *unused) void *host = memory_region_get_ram_ptr(rom->mr); memcpy(host, rom->data, rom->datasize); } else { - cpu_physical_memory_write_rom(rom->as, rom->addr, rom->data, - rom->datasize); + address_space_write_rom(rom->as, rom->addr, MEMTXATTRS_UNSPECIFIED, + rom->data, rom->datasize); } if (rom->isrom) { /* rom needs to be written only once */ diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 97ffdd820f2..c9dd65b3a03 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -122,9 +122,10 @@ static void apic_sync_vapic(APICCommonState *s, int sync_type) } vapic_state.irr = vector & 0xff; - cpu_physical_memory_write_rom(&address_space_memory, - s->vapic_paddr + start, - ((void *)&vapic_state) + start, length); + address_space_write_rom(&address_space_memory, + s->vapic_paddr + start, + MEMTXATTRS_UNSPECIFIED, + ((void *)&vapic_state) + start, length); } } diff --git a/hw/misc/tz-mpc.c b/hw/misc/tz-mpc.c index e0c58ba37ec..fb48a1540b9 100644 --- a/hw/misc/tz-mpc.c +++ b/hw/misc/tz-mpc.c @@ -448,7 +448,7 @@ static int tz_mpc_attrs_to_index(IOMMUMemoryRegion *iommu, MemTxAttrs attrs) { /* We treat unspecified attributes like secure. Transactions with * unspecified attributes come from places like - * cpu_physical_memory_write_rom() for initial image load, and we want + * rom_reset() for initial image load, and we want * those to pass through the from-reset "everything is secure" config. * All the real during-emulation transactions from the CPU will * specify attributes. diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 3c29b68e67f..639906cca30 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -559,8 +559,9 @@ static void idreg_init(hwaddr addr) s = SYS_BUS_DEVICE(dev); sysbus_mmio_map(s, 0, addr); - cpu_physical_memory_write_rom(&address_space_memory, - addr, idreg_data, sizeof(idreg_data)); + address_space_write_rom(&address_space_memory, addr, + MEMTXATTRS_UNSPECIFIED, + idreg_data, sizeof(idreg_data)); } #define MACIO_ID_REGISTER(obj) \ diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst index 57d8c524bfe..c74cd090e64 100644 --- a/docs/devel/loads-stores.rst +++ b/docs/devel/loads-stores.rst @@ -253,6 +253,22 @@ Regexes for git grep - ``\`` - ``\`` +``address_space_write_rom`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This function performs a write by physical address like +``address_space_write``, except that if the write is to a ROM then +the ROM contents will be modified, even though a write by the guest +CPU to the ROM would be ignored. This is used for non-guest writes +like writes from the gdb debug stub or initial loading of ROM contents. + +Note that portions of the write which attempt to write data to a +device will be silently ignored -- only real RAM and ROM will +be written to. + +Regexes for git grep + - ``address_space_write_rom`` + ``{ld,st}*_phys`` ~~~~~~~~~~~~~~~~~ @@ -315,25 +331,6 @@ For new code they are better avoided: Regexes for git grep - ``\`` -``cpu_physical_memory_write_rom`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -This function performs a write by physical address like -``address_space_write``, except that if the write is to a ROM then -the ROM contents will be modified, even though a write by the guest -CPU to the ROM would be ignored. - -Note that unlike ``cpu_physical_memory_write()`` this function takes -an AddressSpace argument, but unlike ``address_space_write()`` this -function does not take a ``MemTxAttrs`` or return a ``MemTxResult``. - -**TODO**: we should probably clean up this inconsistency and -turn the function into ``address_space_write_rom`` with an API -matching ``address_space_write``. - -``cpu_physical_memory_write_rom`` - - ``cpu_memory_rw_debug`` ~~~~~~~~~~~~~~~~~~~~~~~ From patchwork Fri Dec 14 14:41:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="BrSaZmwa"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYJF5bkBz9s3q for ; Sat, 15 Dec 2018 01:45:49 +1100 (AEDT) Received: from localhost ([::1]:33890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXoip-0003Gi-9R for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:45:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofY-0008Mf-8V for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofX-0004HD-Hw for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:24 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:52671) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofX-0004Gb-AM for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:23 -0500 Received: by mail-wm1-x329.google.com with SMTP id m1so5920123wml.2 for ; Fri, 14 Dec 2018 06:42:23 -0800 (PST) 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=GzpwMa38pQNumScrhj2AwYOdGCjzti50x95h3MK8yCc=; b=BrSaZmwamcAy99X3UDRTQETuZQy9YlSeyCMmteKWAa9nmik/ALpA21rTOcuZaESgS5 eBEd0o7CbdzNvnM7KszZMWvI1h9ZMi7Esh/g1r7fdCUHjLDB/4GhCVD54kUVO8Few4Ve pb5Jnvf+rm3BOkBNssDh5ZI5nlw+vT2gaEWy4= 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=GzpwMa38pQNumScrhj2AwYOdGCjzti50x95h3MK8yCc=; b=jhNuFDfX8YnxZxSVoez0Tafn5AIE6pjEsJUFisCbD6t+KDX3uH/ccz1ZSU0GnavEym PFshdEUT7tZ7j0YHcau4GZ4N27Rv+GbEg9A9Rzm5ZNW9Ek4E2vPKAAgvVP2U2vfxoyue cIxfkr8vA2RdXupxQQIDmVxUh/DYZI9DQc6LQh5xeHcjHsEOEZrjlWZmf/ApT1oIhz3i HpJul5so/BKqTNicVqHfk4qfPGO880ig06hYgUNM45EAkY1fyWXtmO/Gywbf7cIzUWDl yoMjux4tvBxZpWSAbqJp1u17eYj5IjRMrXZ4kiPp3PPoTnTl0DKVHVmasc4wQGt/Zo2i +HMg== X-Gm-Message-State: AA+aEWbrqQWEXENIbyqqrY2UA9gvoWeAzApjIZ6OdYyzoWm5f5/r2ue3 7hQNa5qUcUX9alsP3KmD9Pke4K8MLMk= X-Google-Smtp-Source: AFSGD/W3zvqDdTV0B5GYVXJ4nR1Gi7ripvW2j0PJFI0EIL2/EcoUOycMhiVIk/eX6UOvGkj8nqkoBw== X-Received: by 2002:a1c:7619:: with SMTP id r25mr3760070wmc.7.1544798542085; Fri, 14 Dec 2018 06:42:22 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:21 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:41:56 +0000 Message-Id: <20181214144214.1260-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 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 04/22] disas.c: Use address_space_read() to read memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Currently disas.c reads physical memory using cpu_physical_memory_read(). This effectively hard-codes assuming that all CPUs have the same view of physical memory. Switch to address_space_read() instead, which lets us use the AddressSpace for the CPU we're disassembling for. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20181122172653.3413-2-peter.maydell@linaro.org --- disas.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/disas.c b/disas.c index 5325b7e6be6..f9c517b3588 100644 --- a/disas.c +++ b/disas.c @@ -588,7 +588,10 @@ static int physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, struct disassemble_info *info) { - cpu_physical_memory_read(memaddr, myaddr, length); + CPUDebug *s = container_of(info, CPUDebug, info); + + address_space_read(s->cpu->as, memaddr, MEMTXATTRS_UNSPECIFIED, + myaddr, length); return 0; } From patchwork Fri Dec 14 14:41:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ODUZzrB/"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYN85H9Hz9sBQ for ; Sat, 15 Dec 2018 01:49:11 +1100 (AEDT) Received: from localhost ([::1]:33906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXom3-0005md-PB for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:49:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofZ-0008ND-N0 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofY-0004IS-Nf for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:25 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:38704) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofY-0004HW-HE for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:24 -0500 Received: by mail-wr1-x429.google.com with SMTP id v13so5670094wrw.5 for ; Fri, 14 Dec 2018 06:42:24 -0800 (PST) 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=I43XNazY9HryD/pAJPyLhN5QfEXlLPmQ7rLM2tmpOwI=; b=ODUZzrB/ETVbjAJVI805PA/kBAMgf4TZcS3s8UDu9knswDeiQZJhv6uPCsENiEIxBr Bd523fTGtbWh3zTEurTizLjGZNJoy47XSIqxmef4cJueoS9sE46IZQV8TlXws9zh7jM1 32sAxTJc3DYTkITXgvpam9ZZAGvfr/4cSplrQ= 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=I43XNazY9HryD/pAJPyLhN5QfEXlLPmQ7rLM2tmpOwI=; b=P0z57Y6bZE6eGoNPd02LMueQB58rxUrv6vPYPVIqSsncbvEI1Ib5PaPUpSTyoKrE4V EMckciKYQ8QkV12PUsOeG2PHAHGvlAcLeBX2riNEO2r1f66+iK2HaZeRNWSYKsvAMsir 1Sg2FXYBCUfo82cBZ4ncS151Ir+d88nOItt6Z5Y7ULeM0xYujPua+UwqTiQhloBfCIeb pQ3S1qd+7vlZZ5aIbJc8+pub+U120ZnNQFdMa20Yajy/lVLyjZ48gjRlXUd2LlYbdnNa s7co7piBfCv8kyp7Zdj7K+BTkaA9dB3ghsLHBrzyAK4xXOwz8Xs0POX7wOPReqzmIpjS PVkw== X-Gm-Message-State: AA+aEWYcnHXatqktXVDzbeyb9+yYSf9J2Adxbmtm6TUEk3fv++1B7kDB 9rzQJXalCZ4TRbSQP9XgvuNjORESYAY= X-Google-Smtp-Source: AFSGD/UKu9H3r60Twm5/tQzxhCE3aW/19iI0yiwrB0ObSFbXaSYWX3RO6bPG/0SzgcpWfJAuTf9/pQ== X-Received: by 2002:adf:fa90:: with SMTP id h16mr3045066wrr.326.1544798543064; Fri, 14 Dec 2018 06:42:23 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:22 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:41:57 +0000 Message-Id: <20181214144214.1260-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 05/22] monitor: Use address_space_read() to read memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Currently monitor.c reads physical memory using cpu_physical_memory_read(). This effectively hard-codes assuming that all CPUs have the same view of physical memory. Switch to address_space_read() instead, which lets us use the AddressSpace for the CPU we're reading memory for (falling back to address_space_memory if there is no CPU, as happens with the "none" board). As a bonus, this allows us to detect failures to read memory. Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daudé Message-id: 20181122172653.3413-3-peter.maydell@linaro.org --- monitor.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/monitor.c b/monitor.c index 6e81b09294e..4c8d8c2a5a0 100644 --- a/monitor.c +++ b/monitor.c @@ -1605,7 +1605,13 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, if (l > line_size) l = line_size; if (is_physical) { - cpu_physical_memory_read(addr, buf, l); + AddressSpace *as = cs ? cs->as : &address_space_memory; + MemTxResult r = address_space_read(as, addr, + MEMTXATTRS_UNSPECIFIED, buf, l); + if (r != MEMTX_OK) { + monitor_printf(mon, " Cannot access memory\n"); + break; + } } else { if (cpu_memory_rw_debug(cs, addr, buf, l, 0) < 0) { monitor_printf(mon, " Cannot access memory\n"); From patchwork Fri Dec 14 14:41:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013563 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="JNRQFbhM"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYFC4HPxz9s3q for ; Sat, 15 Dec 2018 01:43:11 +1100 (AEDT) Received: from localhost ([::1]:33877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXogH-0008RT-3T for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:43:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofa-0008O1-En for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofZ-0004Jp-Mm for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:26 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:50740) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofZ-0004Iw-Ed for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:25 -0500 Received: by mail-wm1-x32e.google.com with SMTP id n190so5943118wmd.0 for ; Fri, 14 Dec 2018 06:42:25 -0800 (PST) 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=eSGH3yUIJqp943g12rNKyXbza9nJGEMQ75+My45ttjM=; b=JNRQFbhMPJsPn28duH6i0UczJeJ/8zTO/kSgHcfstUMqycKOnPVF7kEtWN8jOq1u4n QoGfWeQLY+8tWSdpu90/ngn2HK7VXRCyFmQ6+vlI1UbV+gkdxVFLWtSjE/VPjLsauCH/ RW/eWYHlkvO62azTcIm8dssqZ//B/p7iFXEt4= 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=eSGH3yUIJqp943g12rNKyXbza9nJGEMQ75+My45ttjM=; b=fMjThkMInJ7WTxpq6Q+EHrh1ouzYro6gAJcpZYkyLnuKYEHbIURL3uaA3liAKkG+90 8ZFhcGOvSNheDICNHALjZpbBR6Gc4kE3GuFN+JfkqEsmXz+YLVN30koA7qAnhMfQwnOo RPQu4F1Rah2NWsMkcaLuB8l5TJDRROreLE2T18EJs4eX/xvqVpwX2fDF+LL50cg7GCzr CrgjO4/WX4HBqUjQFLVveBrWxt21fjXjlVoAgi8vX68yXO7NZcNP6LLsgIdv5YJRKI2N T+YTILrV6yTpKEvt8ed7XoSDIm0hXihDnnIGBHX9bSs10yDAk2xdOzFB2APO1DaoGFfi PRAg== X-Gm-Message-State: AA+aEWYo+hRyBEzRCnr6VrBukeHrX+XjSKgiGsA4D0wFANLVbvIj8VPp OF88CVoLYqFVG1wEAAV4I6fAEhOrkcY= X-Google-Smtp-Source: AFSGD/XjMokjaPRDm/0EmTXROfuH5+HiLA8C0f/oduM2V+XqL1wCOvKoElwfMdmZnmcihc/CnG1T6A== X-Received: by 2002:a7b:c8d7:: with SMTP id f23mr3373191wml.121.1544798544211; Fri, 14 Dec 2018 06:42:24 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:23 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:41:58 +0000 Message-Id: <20181214144214.1260-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 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 06/22] elf_ops.h: Use address_space_write() to write memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Currently the load_elf function in elf_ops.h uses cpu_physical_memory_write() to write the ELF file to memory if it is not handling it as a ROM blob. This means we ignore the AddressSpace that the function is passed to define where it should be loaded. Use address_space_write() instead. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20181122172653.3413-4-peter.maydell@linaro.org --- include/hw/elf_ops.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index 81cecaf27e2..74679ff8da3 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -482,7 +482,9 @@ static int glue(load_elf, SZ)(const char *name, int fd, rom_add_elf_program(label, data, file_size, mem_size, addr, as); } else { - cpu_physical_memory_write(addr, data, file_size); + address_space_write(as ? as : &address_space_memory, + addr, MEMTXATTRS_UNSPECIFIED, + data, file_size); g_free(data); } } From patchwork Fri Dec 14 14:41:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013577 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="aSztM7Vm"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYRr40y8z9sBQ for ; Sat, 15 Dec 2018 01:52:24 +1100 (AEDT) Received: from localhost ([::1]:33923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXopC-0000Zy-4n for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:52:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofe-0008Rx-8F for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofb-0004Kk-3Y for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:30 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:39779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofa-0004Jx-T3 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:27 -0500 Received: by mail-wr1-x430.google.com with SMTP id t27so5674372wra.6 for ; Fri, 14 Dec 2018 06:42:26 -0800 (PST) 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=67NUuZEh6hl7u0ElUf/0ghf8ALMseJ+QqFALOLaub/k=; b=aSztM7VmXTmbeQzQ54+dQeQMvYI4t+vtUmn9CWTK/Ba6kH76yem9qyUx1gpkzpb8v4 kI31n1I4SqfrubBxIuybfP+RsMDMpeQxcoDgCTEykwnAaWEo6RxQvFPXtAyKwApaJShf ncVXJ3Y98j3oNZR7Zlo5E7rPOTqYVy0CwJ0fI= 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=67NUuZEh6hl7u0ElUf/0ghf8ALMseJ+QqFALOLaub/k=; b=Wt4/bCG/1SgF17ZQDqXbJFDbyhznrzkj0nUm0LFPm6BwG9GKbDWuKlESxPeu5uNDrx YAe/LeuNeG9OfknNk4WIwxVfmYU2osQMsR5rDAE+qhFCAi+jVfUubHvuDfrhYN7hplqZ azSNAsIuqOoBbogLqUsn1OplMAXKkZ0KlgS5D/FopbwQ8vUg6bvau2BHZHTUT8CiBrwu vfMP3SN4yahpqwgcsvsoYMITaVaka7bV2dPjgT9DWyLCVSZsheTlAHqWUFPSbkbVzMCk flCcdrFHql8kBnqiK+UuUQAiPrcwMjHHLwCyjhIufLOunIHtVUet4ZK+P2eEIH0X56g1 Wd3Q== X-Gm-Message-State: AA+aEWbC8SpRrXxxXDfh/hQQjP3QJzVLT0tqySgkoO1ubknaPlwtCIuf XJSoXm1Qi5BpXgCLaSibpIz6KgcJhmg= X-Google-Smtp-Source: AFSGD/XlFkztK/xSTcWU0b7gO2xaIUT8NoiM2ODjIM39rym2YCUdd1wIJuSd1oaZR2PQpgC+o7WrJQ== X-Received: by 2002:a5d:620f:: with SMTP id y15mr2774984wru.314.1544798545287; Fri, 14 Dec 2018 06:42:25 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:24 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:41:59 +0000 Message-Id: <20181214144214.1260-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 Subject: [Qemu-devel] [PULL 07/22] hw/ppc/mac_newworld, mac_oldworld: Don't use load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Use the glib g_file_get_contents() function instead, which does the whole "allocate memory for the file and read it in" operation. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Acked-by: David Gibson Message-id: 20181130151712.2312-2-peter.maydell@linaro.org --- hw/ppc/mac_newworld.c | 10 ++++------ hw/ppc/mac_oldworld.c | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 14273a123e5..7e45afae7c5 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -127,8 +127,7 @@ static void ppc_core99_init(MachineState *machine) MACIOIDEState *macio_ide; BusState *adb_bus; MacIONVRAMState *nvr; - int bios_size, ndrv_size; - uint8_t *ndrv_file; + int bios_size; int ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; @@ -510,11 +509,10 @@ static void ppc_core99_init(MachineState *machine) /* MacOS NDRV VGA driver */ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, NDRV_VGA_FILENAME); if (filename) { - ndrv_size = get_image_size(filename); - if (ndrv_size != -1) { - ndrv_file = g_malloc(ndrv_size); - ndrv_size = load_image(filename, ndrv_file); + gchar *ndrv_file; + gsize ndrv_size; + if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) { fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size); } g_free(filename); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 9891c325a9b..817f70e52cf 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -99,8 +99,7 @@ static void ppc_heathrow_init(MachineState *machine) SysBusDevice *s; DeviceState *dev, *pic_dev; BusState *adb_bus; - int bios_size, ndrv_size; - uint8_t *ndrv_file; + int bios_size; uint16_t ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; @@ -361,11 +360,10 @@ static void ppc_heathrow_init(MachineState *machine) /* MacOS NDRV VGA driver */ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, NDRV_VGA_FILENAME); if (filename) { - ndrv_size = get_image_size(filename); - if (ndrv_size != -1) { - ndrv_file = g_malloc(ndrv_size); - ndrv_size = load_image(filename, ndrv_file); + gchar *ndrv_file; + gsize ndrv_size; + if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) { fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size); } g_free(filename); From patchwork Fri Dec 14 14:42:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013573 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EHbYGIw8"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYN85LlMz9sBZ for ; Sat, 15 Dec 2018 01:49:11 +1100 (AEDT) Received: from localhost ([::1]:33904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXom4-0005mP-2v for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:49:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofe-0008Rw-8E for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofb-0004L8-Lx for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:30 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:38711) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofb-0004Ka-FU for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:27 -0500 Received: by mail-wr1-x430.google.com with SMTP id v13so5670263wrw.5 for ; Fri, 14 Dec 2018 06:42:27 -0800 (PST) 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=ehrN3IXVxWmv4DFh+JmYGjJNUd/zUq7PEY6bqwj8mis=; b=EHbYGIw8JYaIKW4qYLV1ermRDKS80TLNpVzCxYVxBU5MBSWkDbmtjc2oZ7YnooXIx+ NsZp3bw+SP3pfnCHsbYyIUXtEKtyNkyLx0aOGvP9CdhmIIy3rkniO09flcwv2M6lB+yy BWkHbBzzMKm50pbexDP5EXbD6r+2jBfBTZHw0= 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=ehrN3IXVxWmv4DFh+JmYGjJNUd/zUq7PEY6bqwj8mis=; b=M1IiSbRG+2qOh4B4/gGJxPbu7Z147FGvXuUPM1ZpsB8Y3uIkpRD0AadPTONhrRspuM CvFkQcJ7e4go5jZBi6zV2zgzaE3wvjLxDRKLCBxEXxElHlNzDrZ74mV9CBtFmDH5nfI5 YjQ+8Mblx+WQ++xwqM36OLXpd4JNyaEXPUk3n/CSYQw+KBnIQM/ItymPHTgLksE8xacj SUygH+CE8MuXexS6H+vXs6ffoDW6xY8fxUAkgL0Zd8TX9dCs2zj/YzGN8JjJWADbArwR ChsA386aYIXESG7VBBdeztckinIhaYe3HjSHMFaUrzmLgCIwRNxpOXl1Gl1KpcOrV6I2 YCKg== X-Gm-Message-State: AA+aEWbsEe3R9zW9kQHIfj8HiMrzmEeb4eRxwML+XOGfn8OK6kEU8rCF ZvUKYHl5Liy0RFLQ5rgUR0oeZENYL4s= X-Google-Smtp-Source: AFSGD/WMinqDYCpuafgKlEjdKAakv8ilVmOTG3ZTzTUNqZdZojCM/9TY/NQm+IDa+RB8/rS4khXntw== X-Received: by 2002:a5d:410e:: with SMTP id l14mr2854917wrp.61.1544798546263; Fri, 14 Dec 2018 06:42:26 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:25 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:00 +0000 Message-Id: <20181214144214.1260-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 Subject: [Qemu-devel] [PULL 08/22] hw/ppc/ppc405_boards: Don't use load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Acked-by: David Gibson Message-id: 20181130151712.2312-3-peter.maydell@linaro.org --- hw/ppc/ppc405_boards.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c index 3be3fe4432b..1b0a0a8ba3a 100644 --- a/hw/ppc/ppc405_boards.c +++ b/hw/ppc/ppc405_boards.c @@ -219,9 +219,11 @@ static void ref405ep_init(MachineState *machine) bios_name = BIOS_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { - bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); + bios_size = load_image_size(filename, + memory_region_get_ram_ptr(bios), + BIOS_SIZE); g_free(filename); - if (bios_size < 0 || bios_size > BIOS_SIZE) { + if (bios_size < 0) { error_report("Could not load PowerPC BIOS '%s'", bios_name); exit(1); } @@ -515,9 +517,11 @@ static void taihu_405ep_init(MachineState *machine) &error_fatal); filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { - bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); + bios_size = load_image_size(filename, + memory_region_get_ram_ptr(bios), + BIOS_SIZE); g_free(filename); - if (bios_size < 0 || bios_size > BIOS_SIZE) { + if (bios_size < 0) { error_report("Could not load PowerPC BIOS '%s'", bios_name); exit(1); } From patchwork Fri Dec 14 14:42:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013575 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jrJ1LHzs"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYRq4HQ9z9s3C for ; Sat, 15 Dec 2018 01:52:23 +1100 (AEDT) Received: from localhost ([::1]:33922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXopB-0000ZS-1p for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:52:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofe-0008S0-8n for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofc-0004Lk-UC for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:30 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:42656) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofc-0004LS-Ns for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:28 -0500 Received: by mail-wr1-x42b.google.com with SMTP id q18so5665379wrx.9 for ; Fri, 14 Dec 2018 06:42:28 -0800 (PST) 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=MMtssPte+19TRFL5+NKOA3qaOUB4Kxoeb5HKsFBULaU=; b=jrJ1LHzs78Y3QEFioDUlf2Mn/gn3ad8igjtxrUFRy379+NmJnNtocI38T/+b5iFIBQ JEN4KFjg6S7EEbk8djukwm/uOLAd11PTOFKEeWdoPZB6XKOPt9U5D+fhMDjwZIt91Sui 3rXod/DjmNF7GXfU7qMxwPGT+PX3fAU7mRjUg= 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=MMtssPte+19TRFL5+NKOA3qaOUB4Kxoeb5HKsFBULaU=; b=LJkqZjGIauH3xm50aOtewmyQPxCL++gX+oJbeX7mbnsKH/PVOljuCBRs8R6NEofNOZ vWllpA410UVfgaA5eMyFk4x37Y3oggJKAm14P7jOVQup44ymaIvqWwCsk5cV/24OJHVQ i9BxqQOlI9nr+4590E7ZQ/Hfo99tmM6VpQ2cmeiwvV5bp+MJouv0pjCu0qu68aCxQ46S 0XaejRd3OvfnIJGrueRSIhJGABEPt/6MdmZ4oT8uRKDjf+VTmtNrNNXnjCzdDQWNXLKr mIdmD9E5GxhspOc8JtDvWT1Hs6mv03/gtTs1/OrfdC509UgogG7BleKPqUlPJSn0ZPwF aGQw== X-Gm-Message-State: AA+aEWaOWkFoUs9E8e23nU9ilAhsWG10CFw+C7imYw/dy5PQ7trktFcW t1Ddk2nRuWltyC3mKXhfGk+Z4kYlk6k= X-Google-Smtp-Source: AFSGD/W25nRSs2zkSKiOz9abvl77Z6gOFkocMXthGTnTIzdk8wUYoJDS7dN0UFUWMTbiZdXNkxInkw== X-Received: by 2002:adf:9d85:: with SMTP id p5mr2725403wre.41.1544798547366; Fri, 14 Dec 2018 06:42:27 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:26 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:01 +0000 Message-Id: <20181214144214.1260-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b Subject: [Qemu-devel] [PULL 09/22] hw/smbios/smbios.c: Don't use load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Message-id: 20181130151712.2312-4-peter.maydell@linaro.org --- hw/smbios/smbios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 920939454e7..04811279a08 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -982,7 +982,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) header = (struct smbios_structure_header *)(smbios_tables + smbios_tables_len); - if (load_image(val, (uint8_t *)header) != size) { + if (load_image_size(val, (uint8_t *)header, size) != size) { error_setg(errp, "Failed to load SMBIOS file %s", val); return; } From patchwork Fri Dec 14 14:42:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dClYfFKF"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYJG5MHKz9sBQ for ; Sat, 15 Dec 2018 01:45:50 +1100 (AEDT) Received: from localhost ([::1]:33888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXoiq-0003Gd-53 for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:45:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXoff-0008T8-Em for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofe-0004Oe-J5 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:31 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:40744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofe-0004NW-Bg for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:30 -0500 Received: by mail-wr1-x429.google.com with SMTP id p4so5659962wrt.7 for ; Fri, 14 Dec 2018 06:42:30 -0800 (PST) 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=kLYPC7Wm3QxM1UYLBDMyWS5Qm4104WlYoADXOtQR4Js=; b=dClYfFKFKTMoCp1PRErSaaXieS+jynevKvLMPRGCmqhbflKyp5HlRBK8Z7KhwQa0kI 4YLrQ5i+MB4K61jeo1Cw2xHRYsvqi2LszKTFUT++VtvkfYk4MuFYLEVA/CPwrkQOveSW Dnd2wkoI1WUFdWs/7OnJbCFo7NthWeFN81LDU= 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=kLYPC7Wm3QxM1UYLBDMyWS5Qm4104WlYoADXOtQR4Js=; b=nTSXwnZHhbCxj06pm6eM/ojPmOdq/LavsX/ipyQZtxEhw88LTZn8/u2AV3hNCVhG+o KMl39isG3q823oqeHq1aF2OtIVnoKDtWNq14OspUYXVUf8Y7W7PpSu8ZpwKVS9iz4rNa qFG05leA4Pcq7/t2knnh3j3GnhrwEFOM5U7FnO9qJIsSbMtagg7QBzWqz3HTj8WkmTSR YDh0MVfX0GR3beiSgb14sRvSNx32dRIsHg6zzZkHewVrj9IY3ZV+VVobkx01KJmaP+1+ ShlSXBOE4hbL/7BNP1oeByOBWRpUt2aa98qqP8+ZshPfg05ZzhcwDMou0AV3s9e+w3Dg tq6w== X-Gm-Message-State: AA+aEWaXnK6Hx4jqEq8HklMdhXRB5CfzwgeEZAWTgAjAaONIHzAoT7p1 IfXJYHksUj5mLOyKgfP0uqU+5oOCsTo= X-Google-Smtp-Source: AFSGD/UBEMgESvyO5wEDvT+dxitRpaOAz6sAMIfRKKzQXmX4LRD5nHoSbMsKErYSyP9GEAftslaKiQ== X-Received: by 2002:adf:e891:: with SMTP id d17mr3087971wrm.140.1544798549134; Fri, 14 Dec 2018 06:42:29 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:27 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:02 +0000 Message-Id: <20181214144214.1260-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 10/22] hw/pci/pci.c: Don't use load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). While we are converting this code, add an error-check for read failure. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Message-id: 20181130151712.2312-5-peter.maydell@linaro.org --- hw/pci/pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 56b13b3320e..efb5ce196ff 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2261,7 +2261,11 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, pdev->has_rom = true; memory_region_init_rom(&pdev->rom, OBJECT(pdev), name, size, &error_fatal); ptr = memory_region_get_ram_ptr(&pdev->rom); - load_image(path, ptr); + if (load_image_size(path, ptr, size) < 0) { + error_setg(errp, "failed to load romfile \"%s\"", pdev->romfile); + g_free(path); + return; + } g_free(path); if (is_default_rom) { From patchwork Fri Dec 14 14:42:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013580 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="i/trfJU4"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYWK2BbPz9s3C for ; Sat, 15 Dec 2018 01:55:23 +1100 (AEDT) Received: from localhost ([::1]:33937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXos5-0003m1-DC for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:55:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofg-0008UK-KI for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXoff-0004Pm-Np for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:32 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:52684) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXoff-0004P9-Gf for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:31 -0500 Received: by mail-wm1-x336.google.com with SMTP id m1so5920534wml.2 for ; Fri, 14 Dec 2018 06:42:31 -0800 (PST) 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=cZyZIbhVG8SvDkMjVAT4schQHteVGKL5jqpp5bWBaGk=; b=i/trfJU4G8Stw11o0dlpWnY67Smg+CIVoB0098CWTaP1uFoNIiXb78aj/G3o+N/wgF d83bVRMTH501uPw/7T6GqP1E2HNPe2dPaUgZTCAY5C7LhnmcyQjo+NGXkQnkp/dsnwxe dhnQe7gmwgmv2RQrfm8z2441S41aMbD4tntc4= 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=cZyZIbhVG8SvDkMjVAT4schQHteVGKL5jqpp5bWBaGk=; b=MnKV95SK3pCZYrQ493CtCrp60hdKDshbh0vj6weSpnMJskIHW3xBdV3rfrnOrTU/zV ioTmL7MUQ9bLD3OWseiZ3my1x6pWckrIBi7kYJZNtCz4ppnrariBgkN/48f6T6W8vZeo MbQGwAS11HDzvA1sg863Q4NgEs2ys8KRrGKSch1iKeLYHtuBZiOf0b3Fhx2Z0LVtnxWA 5MKnNMNzSINI6ZqxXErKx8ntBR6PRCa2E47XaiPBNt8qE9FMXIfG0C6MdoAyvjy6KdGI Pih4Je7BwaRv7/oWzdqaJ4+izkap7wkqPW7LyxIQ6eQd1nzEbO/n+pdGfEyG8KWtrCY5 2ZwA== X-Gm-Message-State: AA+aEWbulGH53FjHWNow4GcT8lQIA/PuY55BuxuA+ctlwboC8//RFf7L vcGQMD1nH5xzoMBYNa+7I7wT3HfO0u8= X-Google-Smtp-Source: AFSGD/XpT9QgIdjf4DpeWri4Od74GslNaG82QdaepziGEN10J2/IejaCqzqm7rOgjqeQVv7ALusfEw== X-Received: by 2002:a1c:96ce:: with SMTP id y197mr3654739wmd.36.1544798550209; Fri, 14 Dec 2018 06:42:30 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:29 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:03 +0000 Message-Id: <20181214144214.1260-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 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 11/22] hw/i386/pc.c: Don't use load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Use the glib g_file_get_contents() function instead, which does the whole "allocate memory for the file and read it in" operation. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Message-id: 20181130151712.2312-6-peter.maydell@linaro.org --- hw/i386/pc.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 4cd2fbca4d5..115bc2825ce 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -839,10 +839,9 @@ static void load_linux(PCMachineState *pcms, { uint16_t protocol; int setup_size, kernel_size, cmdline_size; - int64_t initrd_size = 0; int dtb_size, setup_data_offset; uint32_t initrd_max; - uint8_t header[8192], *setup, *kernel, *initrd_data; + uint8_t header[8192], *setup, *kernel; hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0; FILE *f; char *vmode; @@ -965,27 +964,30 @@ static void load_linux(PCMachineState *pcms, /* load initrd */ if (initrd_filename) { + gsize initrd_size; + gchar *initrd_data; + GError *gerr = NULL; + if (protocol < 0x200) { fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n"); exit(1); } - initrd_size = get_image_size(initrd_filename); - if (initrd_size < 0) { + if (!g_file_get_contents(initrd_filename, &initrd_data, + &initrd_size, &gerr)) { fprintf(stderr, "qemu: error reading initrd %s: %s\n", - initrd_filename, strerror(errno)); + initrd_filename, gerr->message); exit(1); - } else if (initrd_size >= initrd_max) { + } + if (initrd_size >= initrd_max) { fprintf(stderr, "qemu: initrd is too large, cannot support." - "(max: %"PRIu32", need %"PRId64")\n", initrd_max, initrd_size); + "(max: %"PRIu32", need %"PRId64")\n", + initrd_max, (uint64_t)initrd_size); exit(1); } initrd_addr = (initrd_max-initrd_size) & ~4095; - initrd_data = g_malloc(initrd_size); - load_image(initrd_filename, initrd_data); - fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_size); From patchwork Fri Dec 14 14:42:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013582 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="f5B6MV/Q"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYWK4HY2z9sB5 for ; Sat, 15 Dec 2018 01:55:25 +1100 (AEDT) Received: from localhost ([::1]:33938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXos7-0003n5-0Z for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:55:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofh-0008VU-Pr for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofg-0004QN-Mo for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:33 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:39390) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofg-0004Pt-FC for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:32 -0500 Received: by mail-wm1-x330.google.com with SMTP id f81so6003708wmd.4 for ; Fri, 14 Dec 2018 06:42:32 -0800 (PST) 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=Zy7S4o1N56Wl2cznuhDgZ981mBSU7vjCOj8z5aNq8f8=; b=f5B6MV/Q7SnhMvWEv3sji4E7wpBKXEzuJ4nqqGsjWtL4iWfkhfIXhIB9/NnqO7YYNq 1ztPUd3mycy7bx/+6aVp89g2ck815gTsS3AyhxVjzdlp1sLvk3Tdx9ktgdTCj6Q8SqPP YLnJNQt72EoMiUmx1tUPZc7sjp5DE9mzBcvXY= 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=Zy7S4o1N56Wl2cznuhDgZ981mBSU7vjCOj8z5aNq8f8=; b=jEv7P/KXBsvEthrjYgmmt/wf2gP0YhtXzA+uwtljN4bfxqvj9UkKQBof1etOyqDwFS SU+VKoRlQm+5nflA1hc1yJcyWsJo/ALQ4ImBoXdkUOYDK3Xa3IO2wwfK+RqcWtyJjY5D 9gdy8jeJTgnCjt9c5hui6KGosMamR/OB1TvaQ68NLFNlsMtpAYc5o7C7sRrbbUBCS/1U MLwUoIRyFHq5M2KSGK5UaXOakqaFKTz/YcYxRwVSD+3+/o1tYMUaPuwHQ3k8ldIdah9y IQpo7ih8aSlRhUtZmfWxPyfKbSmLevtbUKn8XrM4AUuMdwIyuiUeeGgHIyE1neyJi+ru yOUA== X-Gm-Message-State: AA+aEWaCfZ/KGWFD/2yJ73n00vg8DG3SkyTuyanLDn6bc5Xz5gERC/t8 UoedQXKDhEgT84+AL67tY8XpWOQSgXw= X-Google-Smtp-Source: AFSGD/VgnRsg9TngEZJz7cYJ+Uib16RRKbg1W1puY1sIUkh97zYNZ+YFC14jqkRCuhbQCvfcq5JGfg== X-Received: by 2002:a1c:934b:: with SMTP id v72mr3675507wmd.5.1544798551184; Fri, 14 Dec 2018 06:42:31 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:30 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:04 +0000 Message-Id: <20181214144214.1260-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::330 Subject: [Qemu-devel] [PULL 12/22] hw/i386/multiboot.c: Don't use load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). While we are converting the code, add the missing error check. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Message-id: 20181130151712.2312-7-peter.maydell@linaro.org --- hw/i386/multiboot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 1a4344f5fc3..62340687e8e 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -343,7 +343,11 @@ int load_multiboot(FWCfgState *fw_cfg, mbs.mb_buf_size = TARGET_PAGE_ALIGN(mb_mod_length + mbs.mb_buf_size); mbs.mb_buf = g_realloc(mbs.mb_buf, mbs.mb_buf_size); - load_image(one_file, (unsigned char *)mbs.mb_buf + offs); + if (load_image_size(one_file, (unsigned char *)mbs.mb_buf + offs, + mbs.mb_buf_size - offs) < 0) { + error_report("Error loading file '%s'", one_file); + exit(1); + } mb_add_mod(&mbs, mbs.mb_buf_phys + offs, mbs.mb_buf_phys + offs + mb_mod_length, c); From patchwork Fri Dec 14 14:42:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FbA9QhO8"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYN85PKqz9sBn for ; Sat, 15 Dec 2018 01:49:11 +1100 (AEDT) Received: from localhost ([::1]:33905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXom5-0005mU-2X for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:49:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofi-00005F-Vk for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofi-0004R6-5Y for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:34 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:32826) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofh-0004QX-Pc for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:33 -0500 Received: by mail-wm1-x341.google.com with SMTP id r24so16399604wmh.0 for ; Fri, 14 Dec 2018 06:42:33 -0800 (PST) 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=Pa2SzLOSRHoutbmuSGPu0TfLU6QaGhITjocaPCp8/tw=; b=FbA9QhO8XqwdF31G+PtYa7z+hn6nC/7ttoseUJhag9yk9YcRxajZDwwujfyejqQGaZ M/h14PZVP6z6BJzXAPJVL6Q1xHJ6xi2k+zH0UyplgwYhBybQAjQA0QjPbXS0edV2XOQq p7KJsWCghv973+mEMWV8nUHmQhC1AuGuTTgYc= 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=Pa2SzLOSRHoutbmuSGPu0TfLU6QaGhITjocaPCp8/tw=; b=K6gC0siOPf0yoNUiYNAGDqn39Kt/I4C4sCRf3J8z42tdw46/eBh5fWsqPoeavg019X 0iD+B3RjMdz71qtuIQN0oF0yJy2xxKDnZWINRvAEWM4l+ZqW4DHTzRoJZWsdL1WsZALq yJmUKq5u7VtjBKQORQN7+b9jVvBKpmMCw0Py7M4gtNnoNacqAMNbfgdTQgey6QTt4SG3 Bjx/Lz6lkF0VI7VbJwthbOaN5NyzY39AMhrA5RR2QOfq4xFxPne2tWQReMm5TTu7HBjg atnzkpFfAiWbPUEEOaGM7+krBh5kT8FqPLMF1VaD9t8fI5kqdfbmf5/p3mH1gULy0ZPk IeYA== X-Gm-Message-State: AA+aEWZ67/cFK5t3n26Lb+3NfZyD+TUdnDpXSpBw7qRMfuaMAXD6/3sz LihrnmlWKVgrxnniQakQc8SySGZzqYg= X-Google-Smtp-Source: AFSGD/WSAqkHGMhNOJRflvadE3k+Cx9z9BwwjCZcovQMflV7CRQks9KJbAA/Rc6U5IycsVtdXWuPCA== X-Received: by 2002:a7b:ce17:: with SMTP id m23mr3764302wmc.74.1544798552321; Fri, 14 Dec 2018 06:42:32 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:31 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:05 +0000 Message-Id: <20181214144214.1260-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 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 13/22] hw/block/tc58128.c: Don't use load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Message-id: 20181130151712.2312-8-peter.maydell@linaro.org --- hw/block/tc58128.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/block/tc58128.c b/hw/block/tc58128.c index 808ad76ba60..d0fae248dcc 100644 --- a/hw/block/tc58128.c +++ b/hw/block/tc58128.c @@ -38,7 +38,8 @@ static void init_dev(tc58128_dev * dev, const char *filename) memset(dev->flash_contents, 0xff, FLASH_SIZE); if (filename) { /* Load flash image skipping the first block */ - ret = load_image(filename, dev->flash_contents + 528 * 32); + ret = load_image_size(filename, dev->flash_contents + 528 * 32, + FLASH_SIZE - 528 * 32); if (ret < 0) { if (!qtest_enabled()) { error_report("Could not load flash image %s", filename); From patchwork Fri Dec 14 14:42:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013576 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="kgisGM5R"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYRr1Yx4z9sB5 for ; Sat, 15 Dec 2018 01:52:24 +1100 (AEDT) Received: from localhost ([::1]:33921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXopB-0000ZB-Ma for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:52:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofm-00008J-1i for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofj-0004Rh-C1 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:37 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:51898) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofj-0004RE-0L for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:35 -0500 Received: by mail-wm1-x32e.google.com with SMTP id s14so5926824wmh.1 for ; Fri, 14 Dec 2018 06:42:34 -0800 (PST) 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=BczOP9zqmfzqTxFzarSwCSMPsknT71/oxF9WY4Jkbs0=; b=kgisGM5RpvcmtMD4VtaITxymAISbfJW/LnOIAUACk5a0/tZivl4E/PE3rCW4pQU2cc wnNcHSSvUKBlzv2jRA4pnuU52n/czCi9EsphZcIF84K1Dchcl9pYlyiPhMUqQmVxpLuY 2AQgiZmt7+CcBoKKu3yhTbV6P78DzZ39HG1TQ= 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=BczOP9zqmfzqTxFzarSwCSMPsknT71/oxF9WY4Jkbs0=; b=llKoPFHf6Z+RjCMEzv41DJFzSDRTuh2YnbKlZ7l8tFh7Vlxln4eWiYhJc/OsWvD9Pw HDH46IGtK+77XzOnpGX6/aZNDsJbnUOHzYRxEw0eXnowA+mYwXiwwQAtvVeF6Tu/HYku usrC5bhv3ytsOb1WujEbxiQKuwUf0NRI1eR+EXkY6dx+d/p0HsueAzQ6MzKo+N4VnkMy +j+wL7MKAzigFxJf0wIwSlqy8M9vj7X3rV3Qw7a/D51kXeGR4e03yPNaoqcWh5f5vwF0 s2mQix2D0AN+0mbjxLgmwFJ0cFN1kO7q1Mr/QiW5owjyW9Mm+0esL+vllO0VNLICVWis Edow== X-Gm-Message-State: AA+aEWZ8WehrhszfT71EVg7JSqXRpqRK+OHKJCs/LbOyyUbr1nSFyMG5 SSARWJAgSKXATFQh8DNueGuZJ67h/Eo= X-Google-Smtp-Source: AFSGD/ULRZqYjm0dtiRVYGYuTa1wz0b6e56vGeE3JP8Nxrva8EsDztyVbcARYLSdP9BhpZWY6aoG4g== X-Received: by 2002:a1c:8851:: with SMTP id k78mr3511180wmd.51.1544798553662; Fri, 14 Dec 2018 06:42:33 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:32 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:06 +0000 Message-Id: <20181214144214.1260-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 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 14/22] device_tree.c: Don't use load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Message-id: 20181130151712.2312-9-peter.maydell@linaro.org --- device_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device_tree.c b/device_tree.c index 6d9c9726f66..296278e12ae 100644 --- a/device_tree.c +++ b/device_tree.c @@ -91,7 +91,7 @@ void *load_device_tree(const char *filename_path, int *sizep) /* First allocate space in qemu for device tree */ fdt = g_malloc0(dt_size); - dt_file_load_size = load_image(filename_path, fdt); + dt_file_load_size = load_image_size(filename_path, fdt, dt_size); if (dt_file_load_size < 0) { error_report("Unable to open device tree file '%s'", filename_path); From patchwork Fri Dec 14 14:42:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013586 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Q8+/HcGC"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYcv0svPz9sB5 for ; Sat, 15 Dec 2018 02:00:15 +1100 (AEDT) Received: from localhost ([::1]:33967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXowm-0000Jo-Nt for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 10:00:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofq-0000Cu-F0 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofm-0004T8-8i for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:42 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:41970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofm-0004Rv-0r for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:38 -0500 Received: by mail-wr1-x429.google.com with SMTP id x10so5660893wrs.8 for ; Fri, 14 Dec 2018 06:42:36 -0800 (PST) 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=WylCcXpNI3e1SOD+IH8QOHpe40rwZICYCVd0RnwSEs4=; b=Q8+/HcGCN5QOFG9aGMI0znTLEXkS4SLWWqqYKZoUtma7HtJTyRbpWkofbRgbugvoBe 1gHIGFGXWNzNqyYJiMelyC9J+/6NhWaBvSbDQ8Gnk2/uWeynp4zhAwbXwytSBN3BAvIA 2B9loXKZ+dfxkGF6LLztTcX2B8nqZKo78qg14= 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=WylCcXpNI3e1SOD+IH8QOHpe40rwZICYCVd0RnwSEs4=; b=FfII9qYY4D/9nB10LaKNfEqQVV5FzojOmCnjlOgJ8+zCxmCnWmjxUhRC/YWFFjHKpd suskYAlKMsrokKPJu1o6e3j6MPEYP3hyiJBuCPPNztTlLwlBvIdL/iuTUUF3YBEgjcCi jDr8oMxXNcK2Ac4p7jgZDyjlp591GBQcwubp7+aCVplqOKNqC4v5dK3vELSAkm6e2bnm ihIbeIqQADTFAY0BHWc3J0WX25gKEP+LDnHLKjbZ/C2D0soht4b4DKbBTKDa1+uMgklg gEiUt9MNJ8t6Rhko8bVdVUgbYHQBpNQzV05Qq4gYbPy3u2Zt0AQkV/BAHvzCxQw6WygV A5/g== X-Gm-Message-State: AA+aEWafQ+z0MAEkWtVJLzvlepKG+xZQKmMBTzajwIlwdzjjE669+Zxd sEAKTU/eyEQKaA13jGRm/OWjRZE9yPs= X-Google-Smtp-Source: AFSGD/XEEkJanoXROCTfZk8t+oV428VREJGy4tBpDnesBfeWaK8z2NGR9Lc4YgkSugedOKyIyj3SRA== X-Received: by 2002:adf:c452:: with SMTP id a18mr2895490wrg.145.1544798555050; Fri, 14 Dec 2018 06:42:35 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:34 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:07 +0000 Message-Id: <20181214144214.1260-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 15/22] hw/core/loader.c: Remove load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The load_image() function is now no longer used anywhere, so we can remove it completely. (Use load_image_size() or g_file_get_contents() instead.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Message-id: 20181130151712.2312-10-peter.maydell@linaro.org --- include/hw/loader.h | 1 - hw/core/loader.c | 25 ------------------------- 2 files changed, 26 deletions(-) diff --git a/include/hw/loader.h b/include/hw/loader.h index 67a0af84ac3..3766559bc24 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -11,7 +11,6 @@ * On error, errno is also set as appropriate. */ int64_t get_image_size(const char *filename); -int load_image(const char *filename, uint8_t *addr); /* deprecated */ ssize_t load_image_size(const char *filename, void *addr, size_t size); /**load_image_targphys_as: diff --git a/hw/core/loader.c b/hw/core/loader.c index 66a616608af..fa41842280a 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -73,31 +73,6 @@ int64_t get_image_size(const char *filename) return size; } -/* return the size or -1 if error */ -/* deprecated, because caller does not specify buffer size! */ -int load_image(const char *filename, uint8_t *addr) -{ - int fd, size; - fd = open(filename, O_RDONLY | O_BINARY); - if (fd < 0) - return -1; - size = lseek(fd, 0, SEEK_END); - if (size == -1) { - fprintf(stderr, "file %-20s: get size error: %s\n", - filename, strerror(errno)); - close(fd); - return -1; - } - - lseek(fd, 0, SEEK_SET); - if (read(fd, addr, size) != size) { - close(fd); - return -1; - } - close(fd); - return size; -} - /* return the size or -1 if error */ ssize_t load_image_size(const char *filename, void *addr, size_t size) { From patchwork Fri Dec 14 14:42:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013584 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FpJ2k7rv"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYZ63Nr4z9s3C for ; Sat, 15 Dec 2018 01:57:50 +1100 (AEDT) Received: from localhost ([::1]:33955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXouR-0005jL-Ov for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:57:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofq-0000Cs-E5 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofm-0004TE-9S for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:42 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:35707) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofm-0004SE-2g for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:38 -0500 Received: by mail-wr1-x429.google.com with SMTP id 96so5680232wrb.2 for ; Fri, 14 Dec 2018 06:42:37 -0800 (PST) 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=REjFPA094fKh2KtdwLubWwKQkwwTFmgau+pbtGC2D58=; b=FpJ2k7rvc85/nE2SF+Oebv77ClZ2oQrCsy0xsZPN9bf9DoFd6eyjZI0UWd9jRhL8Em Weesbzd4+s1TyUHJWvVQCwh1nlo+06cikvsDqJinN9yRv3d+xeFZQc8aOOqZZkt9VLvc celCMGPh53inPSw4+aPyPz7giMAOiWdR3Lu+k= 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=REjFPA094fKh2KtdwLubWwKQkwwTFmgau+pbtGC2D58=; b=ItoPQY3QQDpaVADeO3P/CVqjbMLR+C0KCpaOFwc4B7HuQUq5dYEwWIYukcPoM3LCyN J8ZfdfpCEJlIMGLZPUfInM1Oz9KnYljXEcPS6UqOn+iOwMW+ZFGjkq+F8qgy9E+1MKIa TC+ngcNuV8vZLKASPUCZcuysaLVKdabNG75O7wTOS1XS34Tp+g0KCmKZatwHUzqkHZsT KuiXh7xJVUY3LAkxoOMRToCmrCasFZ10sPyPmnXEz2yQHM2LandOaoa+ilG4ihSI5pWO Qzi7U0cG0LYGmcKHW6KhLsUhqmeC1MpIDuXLth27IrP6jXfmLM6xOeJn+ICEAoOrETEm BUSA== X-Gm-Message-State: AA+aEWZuxjVX1VGirYjmJhbcX870Ho6lGbCOekiSOcaaYcxBDyLN4pjU Nr45vq8SzRsaOdVUeTQyvssTflt+YMU= X-Google-Smtp-Source: AFSGD/Wk8Zk2aDpumQqrzDZzoSPtCK+WDHDTl675WkFeOnYWmxVBfgsAoijHiFgZG+PS5WqNMRYPHw== X-Received: by 2002:a5d:634b:: with SMTP id b11mr2885959wrw.14.1544798556040; Fri, 14 Dec 2018 06:42:36 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:35 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:08 +0000 Message-Id: <20181214144214.1260-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 16/22] include/hw/loader.h: Document load_image_size() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add a documentation comment for load_image_size(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Message-id: 20181130151712.2312-11-peter.maydell@linaro.org --- include/hw/loader.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/hw/loader.h b/include/hw/loader.h index 3766559bc24..0a0ad808ea3 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -11,6 +11,22 @@ * On error, errno is also set as appropriate. */ int64_t get_image_size(const char *filename); +/** + * load_image_size: load an image file into specified buffer + * @filename: Path to the image file + * @addr: Buffer to load image into + * @size: Size of buffer in bytes + * + * Load an image file from disk into the specified buffer. + * If the image is larger than the specified buffer, only + * @size bytes are read (this is not considered an error). + * + * Prefer to use the GLib function g_file_get_contents() rather + * than a "get_image_size()/g_malloc()/load_image_size()" sequence. + * + * Returns the number of bytes read, or -1 on error. On error, + * errno is also set as appropriate. + */ ssize_t load_image_size(const char *filename, void *addr, size_t size); /**load_image_targphys_as: From patchwork Fri Dec 14 14:42:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013581 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="bIV05f7v"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYWK5SXNz9sBQ for ; Sat, 15 Dec 2018 01:55:25 +1100 (AEDT) Received: from localhost ([::1]:33939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXos7-0003nX-1s for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:55:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofq-0000Cr-E3 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofo-0004V2-E8 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:42 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:54597) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofm-0004Sa-9V for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:40 -0500 Received: by mail-wm1-x344.google.com with SMTP id a62so5914281wmh.4 for ; Fri, 14 Dec 2018 06:42:38 -0800 (PST) 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=mdARELN2G04Lei1IKxnIVOhSjYEmxk9tWSFqoP1U6u0=; b=bIV05f7v3OEOCYU1o42QcgPMTIAeP+u1wWJCHTCC4PSqRtLX4f/TBCrMqpmUmBzgZ0 4Gsml9MHrLC9lZDJBvCf5zUpjk+ZS9BXlW/JJ8dJk6JVnlFoW6+RIeKbhIjr6T30REKm HBMwziGIkQx2gtFqqm0j/UaHKeHa0apMwKehU= 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=mdARELN2G04Lei1IKxnIVOhSjYEmxk9tWSFqoP1U6u0=; b=DRtxyqDJCpcgPGNuWQTntgK5XCxhe6IkdPiZH5wTJgF5LFX6iMPk2+ys6ZS22uT85z t7sSetR3xpe1UbZQDZywqqWrV8G+1zDybfoEoM9cjBdG/3ueMYur/ZoRA+qIWWl+8tjw hMLA8uLb12ucumpWhmRkJrw7PU1RqMcA+H8xONQp7U2qbJSWiCyTzcDsRWmOdda8ZXPx 71fl/YbqJ7hcEnVSdS7cyY0pp2U2ogX6bqaznJMTrYsoGHqybQpzOBlo02ztjwJc+SCn sd7PW3+4w2y0PWS0FAROSkkrkpd8aHv4ISHmPHVMy/FhPIuyMzoQl03l3AYgLkdglV+T YcKQ== X-Gm-Message-State: AA+aEWbARqp0jnkEHrrUNwtG4weJ8tKKJMwEU/YKTU+AhiHmjP16rxkU kQM83vL8E4u9zcp6kSmFhaDPeaV0nXQ= X-Google-Smtp-Source: AFSGD/XvhjUNsMNRJa/p8eFgxNPyxBwADtnMZwsoqMJ++NAbrz/o23qm6gnG7ek4+Rj+WkANCmINVA== X-Received: by 2002:a1c:1a90:: with SMTP id a138mr3617676wma.109.1544798557099; Fri, 14 Dec 2018 06:42:37 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:36 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:09 +0000 Message-Id: <20181214144214.1260-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 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 17/22] target/arm: Free name string in ARMCPRegInfo hashtable entries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When we add a new entry to the ARMCPRegInfo hash table in add_cpreg_to_hashtable(), we allocate memory for tehe ARMCPRegInfo struct itself, and we also g_strdup() the name string. So the hashtable's value destructor function must free the name string as well as the struct. Spotted by clang's leak sanitizer. The leak here is a small one-off leak at startup, because we don't support CPU hotplug, and so the only time when we destroy hash table entries is for the case where ARM_CP_OVERRIDE means we register a wildcard entry and then override it later. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20181204132952.2601-2-peter.maydell@linaro.org --- target/arm/cpu.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 60411f6bfe0..b84a6c0e678 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -642,6 +642,20 @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) return (Aff1 << ARM_AFF1_SHIFT) | Aff0; } +static void cpreg_hashtable_data_destroy(gpointer data) +{ + /* + * Destroy function for cpu->cp_regs hashtable data entries. + * We must free the name string because it was g_strdup()ed in + * add_cpreg_to_hashtable(). It's OK to cast away the 'const' + * from r->name because we know we definitely allocated it. + */ + ARMCPRegInfo *r = data; + + g_free((void *)r->name); + g_free(r); +} + static void arm_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); @@ -649,7 +663,7 @@ static void arm_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env; cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal, - g_free, g_free); + g_free, cpreg_hashtable_data_destroy); QLIST_INIT(&cpu->pre_el_change_hooks); QLIST_INIT(&cpu->el_change_hooks); From patchwork Fri Dec 14 14:42:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Y7RYWs18"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYZ31LJlz9s3C for ; Sat, 15 Dec 2018 01:57:47 +1100 (AEDT) Received: from localhost ([::1]:33953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXouO-0005gu-Du for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:57:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofr-0000Dp-Bc for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofq-0004Wn-DB for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:43 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:55821) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofo-0004Tk-By for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:40 -0500 Received: by mail-wm1-x32a.google.com with SMTP id y139so5871080wmc.5 for ; Fri, 14 Dec 2018 06:42:39 -0800 (PST) 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=EDEy9U2NQkSWRCiqTG9xAk6L5Uf4CHx4nC2Waqkj4ZI=; b=Y7RYWs18pPePiLG4+MyKn352A7syBcY9DoceIZK4+AzmhPi9yx3mkpJAqbSVte/JT/ YW0nDrBlWGsQKNijd32TalIt0xTJWyXA6LdQtpYbjHncQ9My9VLkbNRyC1QMTvJpJzz2 PYeqYyDuoas+N0fs2TWiHEsOKFT3iPqelN7Gw= 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=EDEy9U2NQkSWRCiqTG9xAk6L5Uf4CHx4nC2Waqkj4ZI=; b=MJ1x0Mcdx4xthUwCR3pvJDWvHi98AdHt8Tt68YsNWRsfjOZyv0PP36VnynxABKumxv +eo9zZLtVOadszx8bzhHG9cLmmyFJbTb9MlEFjxj2FUNBWyZESNMfhSTmS4Q0M8H5zqe Ia9EomczvNd1W7Mpto8bi+wbsXYBT75umZnO8hNotShfWWiST0KKfXS1PXmUWuO6ADJG LzV3HvKKllzNB01s6jaeS4WM/Dte3HeHAczoOB+Fp4uKM+vLfcbkO7w8JxRynJc/WM6F 3YNfoNy5ZJNNXWr38wb9irQw2cO9p2QLptsHrRSxoAazU85Ma+tt5GQzH3PpJvrfw+nb k5XA== X-Gm-Message-State: AA+aEWar7LSA4h3/DShkAuG0H7OWv3asLLOEFavLO6OIkUoiDbrIBeN5 fWUr9GBtpK4mi9SUYpDM7sOMEJjqKlA= X-Google-Smtp-Source: AFSGD/VsFgLESzP32jDMqj0La4tEUjB7h59g/86IToceqmelblf1EBk0xKyCcLbn+jvtjTXRF9ZYlQ== X-Received: by 2002:a1c:7ec4:: with SMTP id z187mr3435390wmc.43.1544798557998; Fri, 14 Dec 2018 06:42:37 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:37 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:10 +0000 Message-Id: <20181214144214.1260-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32a Subject: [Qemu-devel] [PULL 18/22] hw/arm/mps2-tz.c: Free mscname string in make_dma() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The clang leak sanitizer spots a (one-off, trivial) memory leak in make_dma() due to a missing free. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20181204132952.2601-3-peter.maydell@linaro.org --- hw/arm/mps2-tz.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c index 6dd02ae47e8..82b1d020a58 100644 --- a/hw/arm/mps2-tz.c +++ b/hw/arm/mps2-tz.c @@ -322,6 +322,7 @@ static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque, sysbus_connect_irq(s, 2, qdev_get_gpio_in_named(iotkitdev, "EXP_IRQ", 57 + i * 3)); + g_free(mscname); return sysbus_mmio_get_region(s, 0); } From patchwork Fri Dec 14 14:42:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013587 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dSRxZ5PJ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYgD5MQZz9s3C for ; Sat, 15 Dec 2018 02:02:16 +1100 (AEDT) Received: from localhost ([::1]:33987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXoyk-0001nh-2Y for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 10:02:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofr-0000EK-NK for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofq-0004XI-OR for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:43 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:36867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofq-0004UL-G0 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:42 -0500 Received: by mail-wm1-x332.google.com with SMTP id g67so6030163wmd.2 for ; Fri, 14 Dec 2018 06:42:40 -0800 (PST) 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=2GPyWqSYkAEFqDz7mP26xlhA8vIsr5qfNrs56IHVHVM=; b=dSRxZ5PJTZmn9S3pZHWaAHTbZ9UAMGNNg12i5slmdsHg19vxvUqXvXrFBp4CSeCZJz F3FVLHKX+D8XgvVitbtDQy738+1SXrf8BRZG/orHNAaGdUY8VBEZeQJu9+MukamKIojR Pcnls72vh877CoRjbYcz17I3mAwuDdz750ZGA= 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=2GPyWqSYkAEFqDz7mP26xlhA8vIsr5qfNrs56IHVHVM=; b=DwxMNAIMuBtNcBnS28EJdC2/Tkv53iIB6aBrdQ/AVvEGcXAfZJGISl8HMCj+ZsY+t9 uUBg+1trpPgOsQRS0N31H+vD/9bdNjU5VKafAiB8roCu9rA8ZVud/O4GQ+iHoNymMJ6P G10IGf9tahYenkM3q+0FVwhbDr6LkCGh5qp4btwPWIeXh+hPRau7NiBKZUW+NITT6wjV Aaw3yrKfHjc+ISylczGgV74/Ag2uxu5miZDgIlROFNiAmK0lUbRQVXjLqaARMzoMibFn RBGhGhK2SiW/vCQRaC5yHhikkc5ZiS730LPe944C4Uyc4yqsQkfzTJoHInOB2O1OEMbX axcQ== X-Gm-Message-State: AA+aEWYOhv0hiQjDboSwrigcLczec2F3H1jbVDlZssGgzj/8RDHy8N4R xB4dQvomGLFyetevoqGClCPMVwgb2Kg= X-Google-Smtp-Source: AFSGD/USLCwqifMUDQyOlBR1MNI8uP5OZrdsTD42jzzppPdrBfRTAvlqwsv0BaAvB9yPxZvci3Qw4g== X-Received: by 2002:a7b:c8d7:: with SMTP id f23mr3373900wml.121.1544798559109; Fri, 14 Dec 2018 06:42:39 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:38 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:11 +0000 Message-Id: <20181214144214.1260-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PULL 19/22] hw/sd/sdhci: Don't leak memory region in sdhci_sysbus_realize() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In sdhci_sysbus_realize() we override the initialization of s->iomem that sdhci_common_realize() performs. However we don't destroy the old memory region before reinitializing it, which means that the memory allocated for mr->name in memory_region_do_init() is leaked. Since sdhci_initfn() already initializes s->io_ops to &sdhci_mmio_ops, always use that in sdhci_common_realize() and remove the now-unnecessary reinitialization of the MMIO region from sdhci_sysbus_realize(). Spotted by clang's leak sanitizer. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20181204132952.2601-4-peter.maydell@linaro.org --- hw/sd/sdhci.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 81bbf032794..83f1574ffdc 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1371,7 +1371,7 @@ static void sdhci_common_realize(SDHCIState *s, Error **errp) s->buf_maxsz = sdhci_get_fifolen(s); s->fifo_buffer = g_malloc0(s->buf_maxsz); - memory_region_init_io(&s->iomem, OBJECT(s), &sdhci_mmio_ops, s, "sdhci", + memory_region_init_io(&s->iomem, OBJECT(s), s->io_ops, s, "sdhci", SDHC_REGISTERS_MAP_SIZE); } @@ -1565,9 +1565,6 @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp) sysbus_init_irq(sbd, &s->irq); - memory_region_init_io(&s->iomem, OBJECT(s), s->io_ops, s, "sdhci", - SDHC_REGISTERS_MAP_SIZE); - sysbus_init_mmio(sbd, &s->iomem); } From patchwork Fri Dec 14 14:42:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="QgO2H34F"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYND3w5Fz9s3q for ; Sat, 15 Dec 2018 01:49:16 +1100 (AEDT) Received: from localhost ([::1]:33908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXom9-0005ri-PJ for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:49:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofs-0000Ew-C6 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofq-0004Xz-TW for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:44 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:39783) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofq-0004Vp-Gl for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:42 -0500 Received: by mail-wr1-x433.google.com with SMTP id t27so5675190wra.6 for ; Fri, 14 Dec 2018 06:42:41 -0800 (PST) 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=ocJ+E5sOMsP8YGN7X2pKhQSITlDRtDfGO4yqEUdDpnc=; b=QgO2H34FnOqHaHw6XybHUFJoiiTwqm0ZM9HBtTnzOg2+Nk/r2HSBEjxrydvKNhoLxk tmT9xoeKB+5Gm0Id8PPtaRv3nw72Mqmt+i0hkChLlctHTk0vYnpnfhxzRtxL/3Ok+GV4 LtcTBlmYKFI8h6QcKEJpJoxSQvVmt7fv4UjBg= 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=ocJ+E5sOMsP8YGN7X2pKhQSITlDRtDfGO4yqEUdDpnc=; b=njC8rh3sIaO95FqIb57dv92sM2mUo9/bNkJKojTbY+i/gnvwCcIg+Jkyx9SFUtgm/2 WVPOAcRpU86tW70RrTQEb96yuBBc9amk5ziaD7jw3Rz/MAUr3sLlnF+XM0okrgxbstKN MMlGHYE4pfBObWW5ciz4SfNvfSs4yWjH2O7EOwBhjnEyrLYjSEzXvfmiJJmUPX0SWl/f crAdBf0BsKOtyseVws6n/qPpo2P/hl2y04OXqlx/6hGOOOvtOllQrN2/3u6Rqa4Eej3l GK0L7aC2C8SQlyLzmsqCwxia198aS1j0XsJb4IEqXTRCJuTewVwtnQXekBEdQMfobMU0 3Yow== X-Gm-Message-State: AA+aEWbjSCABBH7lHgoKypzOPOYWBUCpwzv39bp8rpn/WcUTRpnQZ9k/ CWOnGRkJPTRx0iscvlYeHkUsVlwg8qE= X-Google-Smtp-Source: AFSGD/WGorvghXrjdKEN6BaV0DgkdbtXXeBpQ2YpvHBCoSuSqkhmcyTmbU1UHbryMphK+UnYUW+/mA== X-Received: by 2002:adf:b783:: with SMTP id s3mr3005964wre.274.1544798560167; Fri, 14 Dec 2018 06:42:40 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:39 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:12 +0000 Message-Id: <20181214144214.1260-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 Subject: [Qemu-devel] [PULL 20/22] tests/test-arm-mptimer: Don't leak string memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The test-arm-mptimer setup creates a lot of test names using g_strdup_printf() and never frees them. This is entirely harmless since it's one-shot test code, but it clutters up the output from clang's LeakSanitizer. Refactor to use a helper function so we can free the memory. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20181204132952.2601-5-peter.maydell@linaro.org --- tests/test-arm-mptimer.c | 153 ++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 84 deletions(-) diff --git a/tests/test-arm-mptimer.c b/tests/test-arm-mptimer.c index cb8f2df9141..156a39f50dd 100644 --- a/tests/test-arm-mptimer.c +++ b/tests/test-arm-mptimer.c @@ -991,10 +991,25 @@ static void test_timer_zero_load_nonscaled_periodic_to_prescaled_oneshot(void) g_assert_cmpuint(timer_get_and_clr_int_sts(), ==, 0); } +/* + * Add a qtest test that comes in two versions: one with + * a timer scaler setting, and one with the timer nonscaled. + */ +static void add_scaler_test(const char *str, bool scale, + void (*fn)(const void *)) +{ + char *name; + int *scaler = scale ? &scaled : &nonscaled; + + name = g_strdup_printf("%s=%d", str, *scaler); + qtest_add_data_func(name, scaler, fn); + g_free(name); +} + int main(int argc, char **argv) { - int *scaler = &nonscaled; int ret; + int scale; g_test_init(&argc, &argv, NULL); @@ -1012,89 +1027,59 @@ int main(int argc, char **argv) qtest_add_func("mptimer/prescaler", test_timer_prescaler); qtest_add_func("mptimer/prescaler_on_the_fly", test_timer_prescaler_on_the_fly); -tests_with_prescaler_arg: - qtest_add_data_func( - g_strdup_printf("mptimer/oneshot scaler=%d", *scaler), - scaler, test_timer_oneshot); - qtest_add_data_func( - g_strdup_printf("mptimer/pause scaler=%d", *scaler), - scaler, test_timer_pause); - qtest_add_data_func( - g_strdup_printf("mptimer/reload scaler=%d", *scaler), - scaler, test_timer_reload); - qtest_add_data_func( - g_strdup_printf("mptimer/periodic scaler=%d", *scaler), - scaler, test_timer_periodic); - qtest_add_data_func( - g_strdup_printf("mptimer/oneshot_to_periodic scaler=%d", *scaler), - scaler, test_timer_oneshot_to_periodic); - qtest_add_data_func( - g_strdup_printf("mptimer/periodic_to_oneshot scaler=%d", *scaler), - scaler, test_timer_periodic_to_oneshot); - qtest_add_data_func( - g_strdup_printf("mptimer/set_oneshot_counter_to_0 scaler=%d", *scaler), - scaler, test_timer_set_oneshot_counter_to_0); - qtest_add_data_func( - g_strdup_printf("mptimer/set_periodic_counter_to_0 scaler=%d", *scaler), - scaler, test_timer_set_periodic_counter_to_0); - qtest_add_data_func( - g_strdup_printf("mptimer/noload_oneshot scaler=%d", *scaler), - scaler, test_timer_noload_oneshot); - qtest_add_data_func( - g_strdup_printf("mptimer/noload_periodic scaler=%d", *scaler), - scaler, test_timer_noload_periodic); - qtest_add_data_func( - g_strdup_printf("mptimer/zero_load_oneshot scaler=%d", *scaler), - scaler, test_timer_zero_load_oneshot); - qtest_add_data_func( - g_strdup_printf("mptimer/zero_load_periodic scaler=%d", *scaler), - scaler, test_timer_zero_load_periodic); - qtest_add_data_func( - g_strdup_printf("mptimer/zero_load_oneshot_to_nonzero scaler=%d", *scaler), - scaler, test_timer_zero_load_oneshot_to_nonzero); - qtest_add_data_func( - g_strdup_printf("mptimer/zero_load_periodic_to_nonzero scaler=%d", *scaler), - scaler, test_timer_zero_load_periodic_to_nonzero); - qtest_add_data_func( - g_strdup_printf("mptimer/nonzero_load_oneshot_to_zero scaler=%d", *scaler), - scaler, test_timer_nonzero_load_oneshot_to_zero); - qtest_add_data_func( - g_strdup_printf("mptimer/nonzero_load_periodic_to_zero scaler=%d", *scaler), - scaler, test_timer_nonzero_load_periodic_to_zero); - qtest_add_data_func( - g_strdup_printf("mptimer/set_periodic_counter_on_the_fly scaler=%d", *scaler), - scaler, test_timer_set_periodic_counter_on_the_fly); - qtest_add_data_func( - g_strdup_printf("mptimer/enable_and_set_counter scaler=%d", *scaler), - scaler, test_timer_enable_and_set_counter); - qtest_add_data_func( - g_strdup_printf("mptimer/set_counter_and_enable scaler=%d", *scaler), - scaler, test_timer_set_counter_and_enable); - qtest_add_data_func( - g_strdup_printf("mptimer/oneshot_with_counter_0_on_start scaler=%d", *scaler), - scaler, test_timer_oneshot_with_counter_0_on_start); - qtest_add_data_func( - g_strdup_printf("mptimer/periodic_with_counter_0_on_start scaler=%d", *scaler), - scaler, test_timer_periodic_with_counter_0_on_start); - qtest_add_data_func( - g_strdup_printf("mptimer/periodic_counter scaler=%d", *scaler), - scaler, test_periodic_counter); - qtest_add_data_func( - g_strdup_printf("mptimer/set_counter_periodic_with_zero_load scaler=%d", *scaler), - scaler, test_timer_set_counter_periodic_with_zero_load); - qtest_add_data_func( - g_strdup_printf("mptimer/set_oneshot_load_to_0 scaler=%d", *scaler), - scaler, test_timer_set_oneshot_load_to_0); - qtest_add_data_func( - g_strdup_printf("mptimer/set_periodic_load_to_0 scaler=%d", *scaler), - scaler, test_timer_set_periodic_load_to_0); - qtest_add_data_func( - g_strdup_printf("mptimer/zero_load_mode_switch scaler=%d", *scaler), - scaler, test_timer_zero_load_mode_switch); - - if (scaler == &nonscaled) { - scaler = &scaled; - goto tests_with_prescaler_arg; + for (scale = 0; scale < 2; scale++) { + add_scaler_test("mptimer/oneshot scaler", + scale, test_timer_oneshot); + add_scaler_test("mptimer/pause scaler", + scale, test_timer_pause); + add_scaler_test("mptimer/reload scaler", + scale, test_timer_reload); + add_scaler_test("mptimer/periodic scaler", + scale, test_timer_periodic); + add_scaler_test("mptimer/oneshot_to_periodic scaler", + scale, test_timer_oneshot_to_periodic); + add_scaler_test("mptimer/periodic_to_oneshot scaler", + scale, test_timer_periodic_to_oneshot); + add_scaler_test("mptimer/set_oneshot_counter_to_0 scaler", + scale, test_timer_set_oneshot_counter_to_0); + add_scaler_test("mptimer/set_periodic_counter_to_0 scaler", + scale, test_timer_set_periodic_counter_to_0); + add_scaler_test("mptimer/noload_oneshot scaler", + scale, test_timer_noload_oneshot); + add_scaler_test("mptimer/noload_periodic scaler", + scale, test_timer_noload_periodic); + add_scaler_test("mptimer/zero_load_oneshot scaler", + scale, test_timer_zero_load_oneshot); + add_scaler_test("mptimer/zero_load_periodic scaler", + scale, test_timer_zero_load_periodic); + add_scaler_test("mptimer/zero_load_oneshot_to_nonzero scaler", + scale, test_timer_zero_load_oneshot_to_nonzero); + add_scaler_test("mptimer/zero_load_periodic_to_nonzero scaler", + scale, test_timer_zero_load_periodic_to_nonzero); + add_scaler_test("mptimer/nonzero_load_oneshot_to_zero scaler", + scale, test_timer_nonzero_load_oneshot_to_zero); + add_scaler_test("mptimer/nonzero_load_periodic_to_zero scaler", + scale, test_timer_nonzero_load_periodic_to_zero); + add_scaler_test("mptimer/set_periodic_counter_on_the_fly scaler", + scale, test_timer_set_periodic_counter_on_the_fly); + add_scaler_test("mptimer/enable_and_set_counter scaler", + scale, test_timer_enable_and_set_counter); + add_scaler_test("mptimer/set_counter_and_enable scaler", + scale, test_timer_set_counter_and_enable); + add_scaler_test("mptimer/oneshot_with_counter_0_on_start scaler", + scale, test_timer_oneshot_with_counter_0_on_start); + add_scaler_test("mptimer/periodic_with_counter_0_on_start scaler", + scale, test_timer_periodic_with_counter_0_on_start); + add_scaler_test("mptimer/periodic_counter scaler", + scale, test_periodic_counter); + add_scaler_test("mptimer/set_counter_periodic_with_zero_load scaler", + scale, test_timer_set_counter_periodic_with_zero_load); + add_scaler_test("mptimer/set_oneshot_load_to_0 scaler", + scale, test_timer_set_oneshot_load_to_0); + add_scaler_test("mptimer/set_periodic_load_to_0 scaler", + scale, test_timer_set_periodic_load_to_0); + add_scaler_test("mptimer/zero_load_mode_switch scaler", + scale, test_timer_zero_load_mode_switch); } qtest_start("-machine vexpress-a9"); From patchwork Fri Dec 14 14:42:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013568 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="RmUxKI4i"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYJN5DG3z9s3q for ; Sat, 15 Dec 2018 01:45:56 +1100 (AEDT) Received: from localhost ([::1]:33893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXoiw-0003L6-57 for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 09:45:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofr-0000EX-UK for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofq-0004Y5-Tr for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:43 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:45417) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofq-0004WR-Kf for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:42 -0500 Received: by mail-wr1-x430.google.com with SMTP id t6so5496390wrr.12 for ; Fri, 14 Dec 2018 06:42:42 -0800 (PST) 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=lzxn6H0KV9fGw+tJYdNAKNL2ruLWOFeL0rES4z8XhzI=; b=RmUxKI4iQz20HsjTOMve/vGYdS9WMeCUmv+1B6PvhUooojSKau8xShb+y7Gor7u+0n mVg+tUwDafLtfbRxPM+f28cGBKbqtmseHPPP9ZmUnWT+JfHzij1sbfAtZU9mkYIsXliG pN0ljLKt/AyUH+q/cLvR/v1fvNc5iW4a1UYPU= 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=lzxn6H0KV9fGw+tJYdNAKNL2ruLWOFeL0rES4z8XhzI=; b=TWOFKLMPR9nwet6F2Aqptd1C96weiZU3nevBO8D5wnZvWc2oies+rXl2WbZj4wjcoG 6xl5q8pDNramVdFAQSGfWGvSr6bS6JztMVYgXCaV/VUwY0WXB8+7VxCD/kWVckj3JgqT UVHYhsIAYLdNT/2irT2nW61qqUBKdyt0f0uf3sOJF+jzSuLyc7KyRUCua4AFOhbVT5jm y/2JGy2wD87xbzAtQAZqAcEbIUJ0i820It0YO7RS1sAoLOG3Mxax//NVAIBgl2a2XV+C IzwdiI+ftlDn+sQIhxb/fH79sUyeCumoqMAsZa1Yj4TTeb/3YT8RAe27Tdq9MmK/n2pa LLeA== X-Gm-Message-State: AA+aEWYNyTlA6ZFwDOgyJiIFps9yv7gx/02LAzrBi59VFtbz3UlkM0yP ak3Pmf35e+R+2I5kqWkqKK0IebKBqsg= X-Google-Smtp-Source: AFSGD/WJ1wVC0niF+SEI7OMXWuMcZIAjxhzus6BC/fLPnKDR2cA3EFCxmtBRyxP5dL3UlZhXZ6SY5w== X-Received: by 2002:adf:a1d2:: with SMTP id v18mr2738193wrv.87.1544798561160; Fri, 14 Dec 2018 06:42:41 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:40 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:13 +0000 Message-Id: <20181214144214.1260-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 Subject: [Qemu-devel] [PULL 21/22] target/arm: Create timers in realize, not init X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The timer_new() function allocates memory; this means that if we call it in the CPU's init method we would need to provide an instance_finalize method to free it. Defer the timer creation to the realize function instead. This fixes a memory leak spotted by clang LeakSanitizer when a CPU object is created for introspection. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20181204132952.2601-6-peter.maydell@linaro.org --- target/arm/cpu.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b84a6c0e678..0e7138c9bfb 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -679,14 +679,6 @@ static void arm_cpu_initfn(Object *obj) qdev_init_gpio_in(DEVICE(cpu), arm_cpu_set_irq, 4); } - cpu->gt_timer[GTIMER_PHYS] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, - arm_gt_ptimer_cb, cpu); - cpu->gt_timer[GTIMER_VIRT] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, - arm_gt_vtimer_cb, cpu); - cpu->gt_timer[GTIMER_HYP] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, - arm_gt_htimer_cb, cpu); - cpu->gt_timer[GTIMER_SEC] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, - arm_gt_stimer_cb, cpu); qdev_init_gpio_out(DEVICE(cpu), cpu->gt_timer_outputs, ARRAY_SIZE(cpu->gt_timer_outputs)); @@ -882,6 +874,15 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) return; } } + + cpu->gt_timer[GTIMER_PHYS] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, + arm_gt_ptimer_cb, cpu); + cpu->gt_timer[GTIMER_VIRT] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, + arm_gt_vtimer_cb, cpu); + cpu->gt_timer[GTIMER_HYP] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, + arm_gt_htimer_cb, cpu); + cpu->gt_timer[GTIMER_SEC] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE, + arm_gt_stimer_cb, cpu); #endif cpu_exec_realizefn(cs, &local_err); From patchwork Fri Dec 14 14:42:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1013585 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="C0PqYgxg"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43GYcq61Jnz9sB5 for ; Sat, 15 Dec 2018 02:00:11 +1100 (AEDT) Received: from localhost ([::1]:33965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXowh-0000Fl-Oz for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2018 10:00:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofs-0000FF-KQ for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofr-0004b8-PM for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:44 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:39785) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofr-0004Xq-GT for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:43 -0500 Received: by mail-wr1-x435.google.com with SMTP id t27so5675320wra.6 for ; Fri, 14 Dec 2018 06:42:43 -0800 (PST) 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=L+rS4ZdoFBMqMMSQ3akGLoyGUbqptjyf0EVZYCmVU3w=; b=C0PqYgxgBuu+Nnnxp0wkVN7XbOe2EXm4MlQV59ez83EsYdnFNwDpKGmnMbyWbRm3ZI hpM1x8KbRZ/XGWgyZUIvu0ILeNtArhUrDQaHAkrFF0GoM1e+XhqBAdzeVBFjq7L1wHjE 8FXvovErWsJ/E+lfJ+nw+nUcSCvSqHZVoNAU0= 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=L+rS4ZdoFBMqMMSQ3akGLoyGUbqptjyf0EVZYCmVU3w=; b=RB9Tx5Bhmi6GFLsNMOmP5bR4aqUawfmYJis6wAM1AIXAe7EC0M7a1iX41RDzmmyPZe L3Lx0GGtFZa8WFFYqghdvF6/SuRRMa6tMmtOfO6KJcF/l8fPl6sW5WZVWGl87QYZSkLE 179r1Bt84DMVDn6luRShGAH3a6QcN1UyMPSqOjmd5wJ/w0ddxJRiTwZlB4ctpVhIrfJt /zlgAr5wsdnpEIcAqlMj+BF3yrdwfZC5P7rsStAlQEgcqzGqjeMLMefh0q/Dk3SQN7Rc 93IjVt98dz//Eut13AOHfAPyshXlKYgHqPbgDL5WBsFLWSe3PhGV30II8ByG4UXgRHjq bQkw== X-Gm-Message-State: AA+aEWb72qG/LU20uDIBaibbunBz6LjmqYac7lh9ksHf2JfJdK5KVlZO 0IpXbzG+9BHpkUiPuBUuG/X+wB3Czkk= X-Google-Smtp-Source: AFSGD/VRXHhRawO8v80t6EAwncnm6TCDWQCNkOp42IEWa/+HR0WYEmw+1LkITjrzdHndUppgYXe4LA== X-Received: by 2002:a5d:410e:: with SMTP id l14mr2855607wrp.61.1544798562283; Fri, 14 Dec 2018 06:42:42 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:41 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:42:14 +0000 Message-Id: <20181214144214.1260-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 Subject: [Qemu-devel] [PULL 22/22] virt: Fix broken indentation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eduardo Habkost I introduced indentation using tabs instead of spaces in another commit. Peter reported the problem, and I failed to fix that before sending my pull request. Reported-by: Peter Maydell Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-id: 20181212003147.29604-1-ehabkost@redhat.com Fixes: 951597607696 ("virt: Eliminate separate instance_init functions") Signed-off-by: Eduardo Habkost 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 17f1b49d11f..5b678237b7d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1854,7 +1854,7 @@ static const TypeInfo virt_machine_info = { .instance_size = sizeof(VirtMachineState), .class_size = sizeof(VirtMachineClass), .class_init = virt_machine_class_init, - .instance_init = virt_instance_init, + .instance_init = virt_instance_init, .interfaces = (InterfaceInfo[]) { { TYPE_HOTPLUG_HANDLER }, { }