Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp698122ybt; Mon, 6 Jul 2020 20:54:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/ct1jm7DHc+oq0md4b/nToYt0gs1TuTTTUTY0kVW2ylXYiHxgn+R+89axBH/NYR2pbg8X X-Received: by 2002:a17:906:cf91:: with SMTP id um17mr45198960ejb.168.1594094051915; Mon, 06 Jul 2020 20:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594094051; cv=none; d=google.com; s=arc-20160816; b=OCzJL9X0Jckl0ZPyUo4yAEFekMLrY7Emw6ORzk+I3BxF7IaoYpjenvtNhjluYLxbCC IKIz72S8Ot2gboQ1hPH3umAvuYKcBnSSQ8xCJg3E+XSPmrVJoC/GdaNM+/L7J/h96bou 8KFkbMHTheGqNBhBx3WH9WI+oyEiZKvpa9hv+bSW2gO83PgmpLQxkROvPSWH3kEzqNQv EuxQHhpQV2/l8qx6+87odjZaXWoGDhAUXBte2gKsFUaOhslki5ZwesK0ktzDLcP7bMgQ FT/lUmaP5GExp9yuCu7ktWNs4Cjw+32Vqk/8W4Yvk7DR5y7pm7IOsgAuZQWqP/3WvMDv a8Lw== 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=n6QCGzWBzwdRunC88ZR2ssAXgvTx6O91V0TzBT8uQq0=; b=SnU43WRKv8R9mhmdJ1ShctmayzEVrVoeJfRW9bUtYZ528JMrmmUt0fhz6rOyx5kcZ6 DSdwV7RrFrUO2df7MI4il/3XqpF/rD15km/r9yM49eAoB98YCpAg1UXwfoGbRA4dgXa3 5vOSk/JKJeTbENxJ3BcVthz5hf3DCcIpxPmxPBcAHqDahEckqv0NoKlak7Db45CQEXG/ arIRH0wkxhcApPVwuZKmEuwWK1ahNuDFw1vwof48NxNvISXruBc9LhqWBKQoU6wl2WrE 6cV0ed9jGN7iCeBGIbunYHpnh8vwVzbpcnpRP77RR2XBc3+6pH4lHbtI6g3q+p6HMMGg glJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="nd3qIUY/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id s14si13987561ejx.43.2020.07.06.20.53.48; Mon, 06 Jul 2020 20:54:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="nd3qIUY/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728182AbgGGDvN (ORCPT + 99 others); Mon, 6 Jul 2020 23:51:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbgGGDvL (ORCPT ); Mon, 6 Jul 2020 23:51:11 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA3EC061755; Mon, 6 Jul 2020 20:51:11 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id e8so19378151pgc.5; Mon, 06 Jul 2020 20:51:11 -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=n6QCGzWBzwdRunC88ZR2ssAXgvTx6O91V0TzBT8uQq0=; b=nd3qIUY/At4MlLKusVkbwpdN1oiC+Y9cFHvVlipTtk8YMPXTa9OWsmko1uBnXTaXbW 1UFuWLLWYJ6K9g9VnuAbEZCDl+A3lW9jdUFeN1o+cX6+coyuyqcoqSJTEeSIVriyaV2f 2yGh+mxkqUMjl69ontdhWVvaoEtemJ/maG6tqRN+QpHBF6FSIw590RLvIcD9s9+qQCTw zJQQPL+zO2XZAvPXxrk7M4bEt4jD/1MOD8EmZ01LxBRwnzxx+sLmk6NNGuz/Nfs7WmAM Ln6m9/EqeufS5lFoWMjOZVx8RURQ0QqDpBWz6ne9atnC9Z4oETRGD4wUjEQLe7zwZtRl D7QQ== 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=n6QCGzWBzwdRunC88ZR2ssAXgvTx6O91V0TzBT8uQq0=; b=SCcV3O/Ym0/cl/j0fzKvTPBBJHB84Ys49pD1buRYZ2G3XRZaoqDx4PlmfBAupKY6EG +fTTHvbSyF+OgrJ6EG6ZfSfXNjuYbukOy9ZbmUkDRCqx6FrZ5/TyIG59a82nDzmSIRyQ 2m04jB+bfyVYxb1geCzynJjGjdwq0ngZ8kH3FOkgnKBffYvDX0jqBYqRkW0NI8Ez6jzl C6nNhYFXtRAWoHY6s6wZEJ3DggX04dqMBL3iww6vhxIPvcMmkP3VtPHiUwZMOs8AQFeG ta/yJfCRZm6RtzeYNsWxjO0aILjkRPFrAcUn6/U8TQDdbZqx5saTPhTMMUNlX8SbeMZx 8QjQ== X-Gm-Message-State: AOAM533O4R4r8RW3nsGNvYETKcoTtilGyJmgxHPA13rfGc1Xb/0Af5no niVHL4b6cVQYPwUq8lH/pKk= X-Received: by 2002:a63:6d42:: with SMTP id i63mr41869559pgc.77.1594093870910; Mon, 06 Jul 2020 20:51:10 -0700 (PDT) Received: from nickserv.localdomain (c-98-33-101-203.hsd1.ca.comcast.net. [98.33.101.203]) by smtp.gmail.com with ESMTPSA id d22sm20466320pfd.105.2020.07.06.20.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 20:51:10 -0700 (PDT) From: Nick Terrell To: Borislav Petkov , Thomas Gleixner 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 , Norbert Lange , Andrew Morton , Nick Terrell Subject: [PATCH v6 6/8] x86: bump ZO_z_extra_bytes margin for zstd Date: Mon, 6 Jul 2020 20:46:02 -0700 Message-Id: <20200707034604.1539157-7-nickrterrell@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200707034604.1539157-1-nickrterrell@gmail.com> References: <20200707034604.1539157-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.27.0