Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1029537ybb; Wed, 8 Apr 2020 15:01:45 -0700 (PDT) X-Google-Smtp-Source: APiQypKJ5N+dz4XkbnlwEYhqYo1BFfNQ0xAZMDp6Gn19c8bMnr7da0EhguOcTEiKX7zRDJVwCC2u X-Received: by 2002:a9d:3e4a:: with SMTP id h10mr7166508otg.349.1586383304936; Wed, 08 Apr 2020 15:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586383304; cv=none; d=google.com; s=arc-20160816; b=pGA7ZYUyBTiXB0NJ9nYgMW4aTGImSYfnMxNglI68+hObfVQziZAMss/2EameeUOOF5 B1NXaO2Tg+j/ZPoJv0gLngXy+2HuqF2jvatbInXMDA9SeqQGDNlryfZcpWxW9DIjqQQX mD4zgkPa1VHuCN0mWqB0vJyAf4JWVKEU//HJTE2S+Cg524ck75WJwCSj0HbJdNzZyHMz LYPKxgJKTSvahT5usiWl67B0Ohi/Q1nObqBI5VqURjjnLjRG056jO5sQO2sTgctjDTJi Pv2sfNRRlAH0K8AQvJUE2mk/p7AtOpgVhJdG0xY2ckw4sNDVHid30Vb4iMyCFOizLzW4 Kh/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q8w6z7ePzBWm8stjHkgclVq8ZQiingis8QFQoH+ZzJU=; b=H3AlEovBk3WIBOEQGFnf9Ku9axOe/T2ctPCWK964KgbXj7TE+yynT7vYZ+oMKpy/+S yGNzQcRxz1/jI4GsbZ5m9sDQNfxd04AFwyaxq6R8Li32PWWN7vA8k3hAJe6/REBjP4RM gU1JgfiiWRqm9gTiEZr9rbN7wnlUq0C6q8eW21VU/8HxLyeLN39efxoVjYojZI1z6Md/ TgJziTQS84MilF1Nfa5QPEvfbzIDd4zRyBhiuHM+FCK1KEnimisiw5CGzSNio7aVF++Q l7SfPQDY6aAYYGQEftXYZVrnrMomLFLDVMia5nt3Gjdm1FL8UDWGbnaMJAz/8NWRluE6 ZQ6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZJI2Q3Fp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22si612777otk.170.2020.04.08.15.01.31; Wed, 08 Apr 2020 15:01:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZJI2Q3Fp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726921AbgDHV4T (ORCPT + 99 others); Wed, 8 Apr 2020 17:56:19 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34463 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbgDHV4S (ORCPT ); Wed, 8 Apr 2020 17:56:18 -0400 Received: by mail-pl1-f194.google.com with SMTP id a23so3049623plm.1; Wed, 08 Apr 2020 14:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q8w6z7ePzBWm8stjHkgclVq8ZQiingis8QFQoH+ZzJU=; b=ZJI2Q3FplBc9C50NyWa9JnEkDRIS0iwq41SNeQS74c7uw0qr29tSN6GmUoVg0IA2bO yK51xogDZYBOE8qUA18n8erAcV3TEexwLy84zVfvdEQM7yLhfl+1chlRsM10GPUXJl/t /W/fG1RUk+E3wmk2V4zacO200uVcjSVDf4dW+zLeyeqCF4kjvBJroDyia+cly5su03yl yihlU7FkN2Dj0lTaNCQc/pF5OHZ5mGujOi7KLPCoe1Hatl6t24FiRGCKmptTkHAF7Dal R5m+Emwe+FdwMmiP1yzGZW5vpE8TC5PvqdDAu8Jqq9ctUNYlmQwyNCxWxIg+ZorpEQX/ nB+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q8w6z7ePzBWm8stjHkgclVq8ZQiingis8QFQoH+ZzJU=; b=gmlI/5x3PTwype7zRb1wy282GUgocpIGChRartBf9OQSKzlK8ebXYYDYlRSn6VzoAZ cckE9XopnTgwtnkxKgqe0j4rEL1xXwzycP1zLM/t0MQJjeZ8fpM8HHAjv79cqagjMONP X+mvroCGZnNpulfLacVr6qYcXJGcPnT3GCF8XG7Z3d8HHtNo4Y/P/IOaj6hwS4wwGZlf xeN4+fN3BY0CZfsMu1p1L7MFj9KYLcFBD/yiGEKV+VdUv3kGPRgMuDpQBtKxyr1LgHPG 3q6eWmNC9MFw/jwYNz8wjppwb79sVDiB885fMD9G6+mstVQCS6weMzJwGyrDWjNhxYvw P5cw== X-Gm-Message-State: AGi0PuZSXSdRHJjECT/PMHSmJnecGEGVOV9d6d1nDA8PygxWz6wluQ7p 7a7XN7hr3VLKMvyJYCPL8yk= X-Received: by 2002:a17:90b:3656:: with SMTP id nh22mr7712665pjb.71.1586382977034; Wed, 08 Apr 2020 14:56:17 -0700 (PDT) Received: from nickserv.localdomain (c-73-222-55-223.hsd1.ca.comcast.net. [73.222.55.223]) by smtp.gmail.com with ESMTPSA id ci13sm459604pjb.16.2020.04.08.14.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 14:56:16 -0700 (PDT) From: Nick Terrell To: Nick Terrell Cc: linux-kernel@vger.kernel.org, Chris Mason , linux-kbuild@vger.kernel.org, x86@kernel.org, gregkh@linuxfoundation.org, Petr Malat , Kees Cook , Kernel Team , Nick Terrell , Adam Borowski , Patrick Williams , rmikey@fb.com, mingo@kernel.org, Patrick Williams , Sedat Dilek Subject: [PATCH v5 6/8] x86: bump ZO_z_extra_bytes margin for zstd Date: Wed, 8 Apr 2020 14:57:09 -0700 Message-Id: <20200408215711.137639-7-nickrterrell@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200408215711.137639-1-nickrterrell@gmail.com> References: <20200408215711.137639-1-nickrterrell@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Terrell Bump the ZO_z_extra_bytes margin for zstd. Zstd needs 3 bytes per 128 KB, and has a 22 byte fixed overhead. Zstd needs to maintain 128 KB of space at all times, since that is the maximum block size. See the comments regarding in-place decompression added in lib/decompress_unzstd.c for details. The existing code is written so that all the compression algorithms use the same ZO_z_extra_bytes. It is taken to be the maximum of the growth rate plus the maximum fixed overhead. The comments just above this diff state that: Reviewed-by: Kees Cook Tested-by: Sedat Dilek Signed-off-by: Nick Terrell --- arch/x86/boot/header.S | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 735ad7f21ab0..6dbd7e9f74c9 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S @@ -539,8 +539,14 @@ pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr # the size-dependent part now grows so fast. # # extra_bytes = (uncompressed_size >> 8) + 65536 +# +# ZSTD compressed data grows by at most 3 bytes per 128K, and only has a 22 +# byte fixed overhead but has a maximum block size of 128K, so it needs a +# larger margin. +# +# extra_bytes = (uncompressed_size >> 8) + 131072 -#define ZO_z_extra_bytes ((ZO_z_output_len >> 8) + 65536) +#define ZO_z_extra_bytes ((ZO_z_output_len >> 8) + 131072) #if ZO_z_output_len > ZO_z_input_len # define ZO_z_extract_offset (ZO_z_output_len + ZO_z_extra_bytes - \ ZO_z_input_len) -- 2.26.0