From patchwork Fri Mar 1 23:05:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 777125 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp1604785wrn; Fri, 1 Mar 2024 15:20:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVr2YFY2NbbpvVBWDqvqacaFmrHcqWLZfXQPXAHcEAL4n+B35CZed2g2Vh7kKFIrnPibCqhLcr8F/E15ZHGgaXJ X-Google-Smtp-Source: AGHT+IEYoO443I5xET/aPSL23Nuydr5x2eFwydBjigyA0Zshn1Z0Byi36DrAwzYhZ/QZi/LUb3Cf X-Received: by 2002:a05:6102:c8b:b0:472:9433:2f8a with SMTP id f11-20020a0561020c8b00b0047294332f8amr3682927vst.4.1709335212748; Fri, 01 Mar 2024 15:20:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709335212; cv=none; d=google.com; s=arc-20160816; b=IMN1Q4lphzgkJ6pmkY5kFfIPuOaLOLDlmPAANkGphOqLsKPQaQmzFs0k6gW2j/OueS MlKnqG+D5bwJWewsl3KYNBE9Chn3Ru8t5IcW5HDozt2fS6ZXLmQWebwgjjDFInWjRD0L u+LXBGUiPoibVs/nl9cnXDbCE/WdsO9SKxpRQTnAlLNFn0DHxRIRmwAdTUJOGEAeVSw9 5ATnkioCE8Ik/gSbEy3naWHzmRfA5BkEHWH7OBLBdYVS8SQQe4UOcvHaBYI5DiJO2wkb AORXQ6MIL+JWY7l/5j5kuJpqRLs0upYHFFAjmdN5K9IBL7x0Q1k9SkAq3ZTeQ0mW/UmK d6vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=tzO2W+WajMGPZKg0sOd9kLpT7E3B/88XAmc0t2vBAHU=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=a539O89HDnQm6bRrG3U6UEZ8BaBKZ6Sb8uXpIM9cbgIfBQu40RUgowpJDFhe64OTDH emPrrXZJQ8prAl3hDTFgJaYugnJ4k9ijuEuJngVkgr9LosalBVvpTTrQh/xDK8sKB17m oh10TwRnWSJvOymAz6IWyQimSzooGSP3lapjMA1b++yDugYad7ROOzkJS6p/q4q+CJrZ jJECNkXSCWrwy0POJJrm92KvJpJah70W6GgrzlXCP8Q7LKpl++hvgQeTfwA2CDvEtPBo WK0u+hl31zMscj0KuBwzo4E7i12nhhjQwInmWOiz5dy6ckzKtOvAt7H9a2wdGDWEMZfF Jh0A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P6m8rL7I; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s16-20020ac87590000000b0042e6f32da95si4270287qtq.711.2024.03.01.15.20.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2024 15:20:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P6m8rL7I; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rgBxl-0004tt-CY; Fri, 01 Mar 2024 18:06:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rgBxg-0004s2-7V for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:06:42 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgBxd-0004EA-Mq for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:06:38 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d94b222a3aso28315965ad.2 for ; Fri, 01 Mar 2024 15:06:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709334396; x=1709939196; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tzO2W+WajMGPZKg0sOd9kLpT7E3B/88XAmc0t2vBAHU=; b=P6m8rL7I1LpNvpheAK8Iy1EoejxP3ojjKmen4VLCaz/iARpx7kZrXva2xSf7JgoAhh ncNpn8GOZhF2kW4t40moKPGQqZdxAn7Eqmkund5Twu6otaKpNsHrPfHsXhaEcb2yFnRx JXOTdahiZCZUZuAB+VwXQD5OYLEwRU/y/yk97DCYu9ZCp6D5DlIiGNC3R0oFmv310gul 3Lj/is+rruP3zLSh5bRid/nZ2/m3tUo14r89DQRN1J/L52sEUmon54PVYNWq0GWl4oIx Nw5h4Q1X5hWBQOZsH/2d6ulT3R846Co3CgiLhL1tu65Bo+imDO9tA9/ivJBkRB2texmy 0EtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709334396; x=1709939196; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tzO2W+WajMGPZKg0sOd9kLpT7E3B/88XAmc0t2vBAHU=; b=H5KGra6BxYE02HgPXgMT1Px+VCgy8W2iMtuJfCKSe5ow/kTrymTHuZdZrlf3PgJOz6 6mGNs4KpgzaWr2mk3vMtAgV3w6sRJHf5d49vdMyMwAq+iQ+usexQmY2VQya1xVzjAJN8 WRYU8PQc2kbMzUS5b9xh//T2mptg7vQpw6pTy+Z+dWwMxwIpkaOLfN1C2ect6CR2138Q wM8M7D89vi+tsvJGAwCWkkdS3qBbsf/XWwcmIic/sZjlM4wy1Bl29murm0l/Q7BGxK38 l0uV3ZYn/1613IU76FcoimUox5hyzg2LHFsez/3GkdpxkPYrAeJSXSHj7D0ZVuWfLF/i 8C9g== X-Gm-Message-State: AOJu0YzdXZKBIQ45NPeltLPgTWw9d1D1y3LLEpZATgb7JWPFVGYCC3Q1 yJsE9Yvg9W1+F+1syhFACoPAgiTvb40QD+Hf1/jv+eK2PLy6J4bSwDkJwkvooJk8qdhoSYe4sae i X-Received: by 2002:a17:902:82c7:b0:1dc:affb:1f50 with SMTP id u7-20020a17090282c700b001dcaffb1f50mr2927967plz.47.1709334396419; Fri, 01 Mar 2024 15:06:36 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id lc11-20020a170902fa8b00b001dc668e145asm3988580plb.200.2024.03.01.15.06.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:06:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 11/60] linux-user/elfload: Write process memory to core file in larger chunks Date: Fri, 1 Mar 2024 13:05:30 -1000 Message-Id: <20240301230619.661008-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301230619.661008-1-richard.henderson@linaro.org> References: <20240301230619.661008-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We do not need to copy pages from guest memory before writing them out. Because vmas are contiguous in host memory, we can write them in one go. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index b8d07d8054..491e754f72 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4551,32 +4551,13 @@ static int elf_core_dump(int signr, const CPUArchState *env) } /* - * Finally we can dump process memory into corefile as well. + * Finally write process memory into the corefile as well. */ for (vma = vma_first(&mm); vma != NULL; vma = vma_next(vma)) { - abi_ulong addr; - abi_ulong end; + size_t size = vma_dump_size(vma); - end = vma->vma_start + vma_dump_size(vma); - - for (addr = vma->vma_start; addr < end; - addr += TARGET_PAGE_SIZE) { - char page[TARGET_PAGE_SIZE]; - int error; - - /* - * Read in page from target process memory and - * write it to coredump file. - */ - error = copy_from_user(page, addr, sizeof (page)); - if (error != 0) { - (void) fprintf(stderr, "unable to dump " TARGET_ABI_FMT_lx "\n", - addr); - errno = -error; - goto out; - } - if (dump_write(fd, page, TARGET_PAGE_SIZE) < 0) - goto out; + if (size && dump_write(fd, g2h_untagged(vma->vma_start), size) < 0) { + goto out; } } errno = 0;