From patchwork Tue Sep 10 19:15:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13799279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67B83EDE9AB for ; Tue, 10 Sep 2024 19:16:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF4BE8D00A6; Tue, 10 Sep 2024 15:16:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA3958D0002; Tue, 10 Sep 2024 15:16:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6B748D00A6; Tue, 10 Sep 2024 15:16:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B4A988D0002 for ; Tue, 10 Sep 2024 15:16:05 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5F4B4A89F9 for ; Tue, 10 Sep 2024 19:16:05 +0000 (UTC) X-FDA: 82549783890.23.119A6E9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id A162710000B for ; Tue, 10 Sep 2024 19:16:03 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CH8d6O8j; dmarc=pass (policy=none) header.from=redhat.com; spf=temperror (imf05.hostedemail.com: error in processing during lookup of david@redhat.com: DNS error) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725995736; a=rsa-sha256; cv=none; b=48FR1QVXGanXqKcP4jPECzs5iwB4T6fv3bRPP2aIEpkwpS+uTXdGh3ApBTiVP0m6I8+xR1 j88uyNJfvp6eFhW4smXruW1Wb/b4fdiDJ7lS3cgzqfMOOWouT4bLEZI55QGp74gqaFBgY0 YpNri+K5QxVqHDaAprjTSpqGvlnU65c= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CH8d6O8j; dmarc=pass (policy=none) header.from=redhat.com; spf=temperror (imf05.hostedemail.com: error in processing during lookup of david@redhat.com: DNS error) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725995736; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ueb83hVIj3hVMTASy964Wv7fO6dBN/axyM8tuEYr7Bc=; b=N2pnD68T1t4G3yOosnFSsdWdwZKu0snO4nmbCF+243znKXpgPTzD3goST0/wNUOUEaGgMk ZGaS/HXWI7Wk+WN4Cnnv2LifBWAQ66EaQLhS3ZwP6LbF4/zRt45UNPvXLBXitdJrZk3o2v 0gyBLy9wxCfo4Hs2oK0hvsyAQllAOf8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725995763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ueb83hVIj3hVMTASy964Wv7fO6dBN/axyM8tuEYr7Bc=; b=CH8d6O8jatP6972tZSXWot/ILOicPcipeQxzb42+UW7bm3kOeg83HEHvRhYiiuREmusn6q m3l+lxn0LQALC62hr7eX7Pt18Cev5ClYxRkDAaxOkvRst4wWIa+syTFU9sJX1USffrQacs QCaUX+LMKiumCEEs3BDV1SDk5nauDXc= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-116-doxVM81dNx2G7XLtemTiQw-1; Tue, 10 Sep 2024 15:15:59 -0400 X-MC-Unique: doxVM81dNx2G7XLtemTiQw-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9738F1955F28; Tue, 10 Sep 2024 19:15:56 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.22.17.222]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E8F6E30001A1; Tue, 10 Sep 2024 19:15:50 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Huth , Cornelia Huck , Janosch Frank , Claudio Imbrenda , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Andrew Morton Subject: [PATCH v1 1/5] s390/kdump: implement is_kdump_kernel() Date: Tue, 10 Sep 2024 21:15:35 +0200 Message-ID: <20240910191541.2179655-2-david@redhat.com> In-Reply-To: <20240910191541.2179655-1-david@redhat.com> References: <20240910191541.2179655-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspam-User: X-Rspamd-Queue-Id: A162710000B X-Rspamd-Server: rspam01 X-Stat-Signature: q9zkfej13n9q5ncxyzjr5fua6d654kdb X-HE-Tag: 1725995763-810294 X-HE-Meta: U2FsdGVkX1/3bWMqgcjFj0XND3gErGSON4uGajKUQRYu/N1WzcBDsyljP+NZsn2pa0c1OROZy8kvOgxAW/9Q2TrQLezgqiSgzaPKzEQ6SoOfHY1vTKdVD7KarBMPLnqQJdiQdatde0OKdpcQNN7QD/x/4v4XiZzGI/DM/cHfoX+zMMhcjP+IF6QexGUlNROEEnOu0PoVLxX9WL0FITJnMzYp9KBOH+L7G78uXGMrWob5fkl6IXstrfUOLVwGcdll3bF1pPAR4UmFQZBPBVfgnBjwsFLd/AAsgzcmU02Xc+uIb1hyNC6XDH8+UvZTxyEQMeGv/tp2dPWrxHuScFJBRbR27wq7ZazIlpsZ9r9p4NBZvoSBFltEDVZAHWQt8da1aK91Y2mEVkDrPsys8eRFgNkuyI/BDxuJ6ehUwTuYMdp3wRnDsW0k99/a99JCfzJ3Hdu5g3giWTcYoTDeuTNOq+6lgk7cXZ2WS2YS/PZY7xBSNexPF+QmH/wjW6dxuFdeJ2XMZQhcHpmm1e7WNzkNl0dMB2RPi5a2/kZAEKPbQ7J9gI8MpNhbL7GryXt408jjDsV6utsWP9JBLQlvHYdDGO7LD23Rtv8mAiCqS0LCTWOKMViyuRZPZv6MV7hpCk1KFuLljfPnRU1QDPtdUs8Yes4l5uq0EVWdTnxEjNwOGwGVTHO/X82KypImNR9iAZHcFKsHM9DbD8cNAjeDjFAFWnGV4Vels7gyBmq99z3uEAMnMQFlzSFJ4T+OgxlaLTfjOclbXVCRzILJ68D8fmXZlbKNdStPlEVQlROfA6UivmYYOVXz5SomRJQYAd4xM4n1C19+9tviWQuuXOBo0BMXX8LDsz1RuYvOI+Yz+i5yCIuHCJ6F7iQmB30fUn/tkEe1xbk1tsuTLuM7PUKc+EAIhB8Opd0ZhtK8BsZYeruw9VfKGrG7Jv995ER/ujDFfqJZwyOt3C0z1pOME/o1NLm s5ql2GXg k7Bh+eWszfLKfepTE2tm4STwdaAbA/Va4dU5ZircrBjRxEglahhc8a+k8OQpOpiESV9fwE4uY6jyv7HJXt+2OdA72Un/1sY1pX1vWdFXrOtQqy71jUiC9ybve6fDtTmAw3dvzHbTSz0pEA9w3nMvmJop1DFwNtTTBscVujHhtAfZJPM/WatD6lfSCbn8I/TBEvXdAH7Lgm4RAeiX2ZD1mQK6qJNn6M1QSGpA+19HMJCMr6t6Pn0BzaNEz4IxoiwVZ/BRzDGEVUqZ7BdWXFQ2vwMGtYKbLx0+fOOdng7LNg03kWNSgxor1cID1DY6Wu7gAhLDJURQi3Zj771Hq313OTwZmNC0wY82KAZo5wCI2O+7Z9TfV+BjY9thGbQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: s390x currently always results in is_kdump_kernel() == false, because it sets "elfcorehdr_addr = ELFCORE_ADDR_MAX;" early during setup_arch to deactivate the elfcorehdr= kernel parameter. Let's follow the powerpc example and implement our own logic. This is required for virtio-mem to reliably identify a kdump environment to not try hotplugging memory. Signed-off-by: David Hildenbrand --- arch/s390/include/asm/kexec.h | 4 ++++ arch/s390/kernel/crash_dump.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/arch/s390/include/asm/kexec.h b/arch/s390/include/asm/kexec.h index 1bd08eb56d5f..bd20543515f5 100644 --- a/arch/s390/include/asm/kexec.h +++ b/arch/s390/include/asm/kexec.h @@ -94,6 +94,9 @@ void arch_kexec_protect_crashkres(void); void arch_kexec_unprotect_crashkres(void); #define arch_kexec_unprotect_crashkres arch_kexec_unprotect_crashkres + +bool is_kdump_kernel(void); +#define is_kdump_kernel is_kdump_kernel #endif #ifdef CONFIG_KEXEC_FILE @@ -107,4 +110,5 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi, int arch_kimage_file_post_load_cleanup(struct kimage *image); #define arch_kimage_file_post_load_cleanup arch_kimage_file_post_load_cleanup #endif + #endif /*_S390_KEXEC_H */ diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c index edae13416196..cca1827d3d2e 100644 --- a/arch/s390/kernel/crash_dump.c +++ b/arch/s390/kernel/crash_dump.c @@ -237,6 +237,12 @@ int remap_oldmem_pfn_range(struct vm_area_struct *vma, unsigned long from, prot); } +bool is_kdump_kernel(void) +{ + return oldmem_data.start && !is_ipl_type_dump(); +} +EXPORT_SYMBOL_GPL(is_kdump_kernel); + static const char *nt_name(Elf64_Word type) { const char *name = "LINUX"; From patchwork Tue Sep 10 19:15:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13799280 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A7B1EDE9AB for ; Tue, 10 Sep 2024 19:16:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 383E18D00A7; Tue, 10 Sep 2024 15:16:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3325C8D0002; Tue, 10 Sep 2024 15:16:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F9E18D00A7; Tue, 10 Sep 2024 15:16:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F26A68D0002 for ; Tue, 10 Sep 2024 15:16:10 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 702AEA8A34 for ; Tue, 10 Sep 2024 19:16:10 +0000 (UTC) X-FDA: 82549784100.18.A5B3373 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id BE79F180010 for ; Tue, 10 Sep 2024 19:16:08 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hro5NJpp; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725995665; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Xq/TMyiVBlIW+rwu1EuyYBMF+1VwzZ0MGyvT9zBb2aI=; b=MqaIfOQaH9sJzgDYIpuwmSg7wz2y1VFxb/NxqwEkbtRGnY1Z16/cRJTs6uSPFkWjKwClfq zM7Aj9YChgoiHSwzYc3EhUIS79G7miODYJrYgFvQBJxxmiSAkNAQ3Bm5eF9/8s8bnXGsop IAY6EWlG+EQV7mvmXxbb/sfsdAISL0o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725995665; a=rsa-sha256; cv=none; b=2HckYvYf7bsjjPY/5EtRP1eZ1W0CpBC9nC6QwUvc7V8SOyBvyhqP3rAxSunAIZM/2FNOnT ThBJDpHkNKA+AUSc1qklChtNfNH/A2wag0wHuVhpzST4pe8MMyRyI+C7k8Hodu75nRSnDi t6lrrEn+zAIQKx7m2cgx80zOGaXAYwg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hro5NJpp; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725995768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xq/TMyiVBlIW+rwu1EuyYBMF+1VwzZ0MGyvT9zBb2aI=; b=hro5NJppvJnZtDrBB60Z5heUGMKyrJQfkySMpPZvrrkD5ejP2fMBB43gw28NlBGW6WMzzX z+iT0zcBBgQlYxPB18lHuCGQWXHeg2d90u5XF+s0GhBVYbS0YuYxniewv2E/uARi18U3aa FXbtZyGTPKnDWDc2TT4YQ9KxGsc64/E= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-xGJCYATCMwGtvkeozeKKzg-1; Tue, 10 Sep 2024 15:16:05 -0400 X-MC-Unique: xGJCYATCMwGtvkeozeKKzg-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EA6F21955F07; Tue, 10 Sep 2024 19:16:02 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.22.17.222]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1E8D730001A1; Tue, 10 Sep 2024 19:15:56 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Huth , Cornelia Huck , Janosch Frank , Claudio Imbrenda , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Andrew Morton Subject: [PATCH v1 2/5] s390/physmem_info: query diag500(STORAGE_LIMIT) to support QEMU/KVM memory devices Date: Tue, 10 Sep 2024 21:15:36 +0200 Message-ID: <20240910191541.2179655-3-david@redhat.com> In-Reply-To: <20240910191541.2179655-1-david@redhat.com> References: <20240910191541.2179655-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Stat-Signature: qgr5urxkfhmjx7zgcwagewbxehu9j376 X-Rspamd-Queue-Id: BE79F180010 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725995768-882753 X-HE-Meta: U2FsdGVkX19PHPiSfmzZkY+0aSaSCSnRxYRKDE9zF+iqtyPeYTMOw+L/Pj8qN8FYNGrvmQaLfjphhEg6uJ27e9frZ8Vmcws12B2S6U3UWs18QG/2wpyy2durCXqBl20WPnTPgcTAgJOgPJoJXj3MAcb1zBoofRPsRxjvpIUdSNtytLf+4H9NJXEwUnrRvWaU2h5mJYki1CC9eVsfvtkJrrGs3GUBPREQPw0m+3ng3lCwCaEa8pFpPByrJJcoJQwVUnJwQa4r8nq8d66IAqpIWgh5gQz1qy3RZ23r8XF34vZrGkE/8UFz7aiPVxNF9exsq4Ae5BB60uKKfbtoqByaHDpvM5Pe0qDCHDJGJrwWM2OmTwTfmOPpgzqCLHlIH6WoF3Zm3oRZMQzqiBavGJCuihfQxgbTRNIzj+/P49moYtX1aeeQPuSX9t1rJLb8+uBsFVhvceQF6Itid8e7w/t81g2zHrFYg0ZKgODK8BM2Kfysv/Cd7NWObvTGr/u1AtWNRxeesPbfnUHx6mfnfFaodKEbunteyY5IHDg5cI8K7q5W9DaizH/RaW9C6RCZofEZU8VdMSpvyObGzhAGXdMoLUUqHOmXNlxyPOz40VKvUz3SJTf5VS+nptEjpE7BRHj18n4ymS+AtGeYEkqXXD0RAXHEj+zAzkCD1Us+mJFIcPcY3DpK0KCMhUHDqzqkKj2fBeqKPbaPDeePHy3dzV+YKsiYn10BK86GvOZe4Ket5nMwDV3ki/bfqr7GPXjqvxZDjsa3V84aewslSggFfOM/4bZ0cV9MtHQFNF0hALgI8EgIUjscuXvSMC9xAJMBrjIeHd2ApYdAIoB7yuDek4dIMyVb3xIFqpOGytjcb0T9VeDuQ1w1uCe2b6qAtCRA+v5H8qEe//f+WtKgEyzwC06M8m9sVwCFb8axKT/YnM224k8QPX3fFlyYfaMAstB9N6glPn9GO8121lZMf130IkC zYyF5fV/ L5TEbLh8oVIpvCBgxEuxQkmexFc9+9GNx3Wh1FKNymyyWOZP/Fc+2J5X/nnZ0IvTt2g+4w+AzTeq9M3ZLe49x4kWGXk4QDY7AONQNVwh0i4fTByC11YaH6jjRfrhaOJqgCLk6n8yfGlQhejn9veEOuB7Cfc2N1DoCVKmVZY4HR9RMMD8Yxl41AY9SF9Qxcz1+hWttcw4JMINKKjRaeYTt8uUsfHniWaF3QxWDUjK3vxImPFlp3ztrNhzcL58/osrfq6UpDrumwivk1nsuvLNWAy3/svoKyK8DMaNL/r3PWDgX1DBbhPM9yBT0A/dC2/JLTG/VqXjSlPqAtCejcJeWnisbxm3PC0DDWcf3BZv53kF2E3TrXgSlCgZVkg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To support memory devices under QEMU/KVM, such as virtio-mem, we have to prepare our kernel virtual address space accordingly and have to know the highest possible physical memory address we might see later: the storage limit. The good old SCLP interface is not suitable for this use case. In particular, memory owned by memory devices has no relationship to storage increments, it is always detected using the device driver, and unaware OSes (no driver) must never try making use of that memory. Consequently this memory is located outside of the "maximum storage increment"-indicated memory range. Let's use our new diag500 STORAGE_LIMIT subcode to query this storage limit that can exceed the "maximum storage increment", and use the existing interfaces (i.e., SCLP) to obtain information about the initial memory that is not owned+managed by memory devices. If a hypervisor does not support such memory devices, the address exposed through diag500 STORAGE_LIMIT will correspond to the maximum storage increment exposed through SCLP. To teach kdump on s390x to include memory owned by memory devices, there will be ways to query the relevant memory ranges from the device via a driver running in special kdump mode (like virtio-mem already implements to filter /proc/vmcore access so we don't end up reading from unplugged device blocks). Signed-off-by: David Hildenbrand --- arch/s390/boot/physmem_info.c | 46 ++++++++++++++++++++++++++-- arch/s390/include/asm/physmem_info.h | 3 ++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/arch/s390/boot/physmem_info.c b/arch/s390/boot/physmem_info.c index 4c9ad8258f7e..9cac8550bdca 100644 --- a/arch/s390/boot/physmem_info.c +++ b/arch/s390/boot/physmem_info.c @@ -109,6 +109,38 @@ static int diag260(void) return 0; } +static int diag500_storage_limit(unsigned long *max_physmem_end) +{ + register unsigned long __nr asm("1") = 0x4; + register unsigned long __storage_limit asm("2") = 0; + unsigned long reg1, reg2; + psw_t old; + + asm volatile( + " mvc 0(16,%[psw_old]),0(%[psw_pgm])\n" + " epsw %[reg1],%[reg2]\n" + " st %[reg1],0(%[psw_pgm])\n" + " st %[reg2],4(%[psw_pgm])\n" + " larl %[reg1],1f\n" + " stg %[reg1],8(%[psw_pgm])\n" + " diag 2,4,0x500\n" + "1: mvc 0(16,%[psw_pgm]),0(%[psw_old])\n" + : [reg1] "=&d" (reg1), + [reg2] "=&a" (reg2), + "+&d" (__storage_limit), + "=Q" (get_lowcore()->program_new_psw), + "=Q" (old) + : [psw_old] "a" (&old), + [psw_pgm] "a" (&get_lowcore()->program_new_psw), + "d" (__nr) + : "memory"); + if (!__storage_limit) + return -EINVAL; + /* convert inclusive end to exclusive end. */ + *max_physmem_end = __storage_limit + 1; + return 0; +} + static int tprot(unsigned long addr) { unsigned long reg1, reg2; @@ -157,7 +189,9 @@ unsigned long detect_max_physmem_end(void) { unsigned long max_physmem_end = 0; - if (!sclp_early_get_memsize(&max_physmem_end)) { + if (!diag500_storage_limit(&max_physmem_end)) { + physmem_info.info_source = MEM_DETECT_DIAG500_STOR_LIMIT; + } else if (!sclp_early_get_memsize(&max_physmem_end)) { physmem_info.info_source = MEM_DETECT_SCLP_READ_INFO; } else { max_physmem_end = search_mem_end(); @@ -170,11 +204,17 @@ void detect_physmem_online_ranges(unsigned long max_physmem_end) { if (!sclp_early_read_storage_info()) { physmem_info.info_source = MEM_DETECT_SCLP_STOR_INFO; + return; } else if (!diag260()) { physmem_info.info_source = MEM_DETECT_DIAG260; - } else if (max_physmem_end) { - add_physmem_online_range(0, max_physmem_end); + return; + } else if (physmem_info.info_source == MEM_DETECT_DIAG500_STOR_LIMIT) { + max_physmem_end = 0; + if (!sclp_early_get_memsize(&max_physmem_end)) + physmem_info.info_source = MEM_DETECT_SCLP_READ_INFO; } + if (max_physmem_end) + add_physmem_online_range(0, max_physmem_end); } void physmem_set_usable_limit(unsigned long limit) diff --git a/arch/s390/include/asm/physmem_info.h b/arch/s390/include/asm/physmem_info.h index f45cfc8bc233..51b68a43e195 100644 --- a/arch/s390/include/asm/physmem_info.h +++ b/arch/s390/include/asm/physmem_info.h @@ -9,6 +9,7 @@ enum physmem_info_source { MEM_DETECT_NONE = 0, MEM_DETECT_SCLP_STOR_INFO, MEM_DETECT_DIAG260, + MEM_DETECT_DIAG500_STOR_LIMIT, MEM_DETECT_SCLP_READ_INFO, MEM_DETECT_BIN_SEARCH }; @@ -107,6 +108,8 @@ static inline const char *get_physmem_info_source(void) return "sclp storage info"; case MEM_DETECT_DIAG260: return "diag260"; + case MEM_DETECT_DIAG500_STOR_LIMIT: + return "diag500 storage limit"; case MEM_DETECT_SCLP_READ_INFO: return "sclp read info"; case MEM_DETECT_BIN_SEARCH: From patchwork Tue Sep 10 19:15:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13799284 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54212EDE9AB for ; Tue, 10 Sep 2024 19:16:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C82FB8D00A8; Tue, 10 Sep 2024 15:16:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C59BB8D0002; Tue, 10 Sep 2024 15:16:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B219E8D00A8; Tue, 10 Sep 2024 15:16:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 93FF38D0002 for ; Tue, 10 Sep 2024 15:16:22 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4558E140851 for ; Tue, 10 Sep 2024 19:16:22 +0000 (UTC) X-FDA: 82549784604.29.21939CB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 63737A000C for ; Tue, 10 Sep 2024 19:16:20 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QI+OYWFe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725995776; a=rsa-sha256; cv=none; b=ObgRQ5I+NDsI23IlW1n0rZJN/goDEL/ErctMBnJ/EKGSzRG0duPkpizbSEYn8EgbIiS4Rc mI45xDfHrLsjzZYsyExeBr61jxZx4eEQLh3bCgs/0cSM67yEN4G/yhooYjyU9ZWRZ+5+7d CFDUp1Z5tU702Vr0GBNZdynp2sBrzYw= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QI+OYWFe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725995776; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=f8jrsz+oSo4UCVf0NzVCWgl3T4VzNafVCQ5XVw1eXHQ=; b=bQvnRwORY0f+YZ0QebrnDeUO7kRKGJeD+QtHk32A3ELHlFlZyfSJBeUUYtiRahMcyah5vh EzIKNrYfbz21Garli3jyP9Nvzp9eHolgMZpvurm5ds5DlnsLnP7KNrHRG2JYv7OKUJUrB1 MA9WOzsj3BOkMDHZwIXeimqmC7Bddm4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725995779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f8jrsz+oSo4UCVf0NzVCWgl3T4VzNafVCQ5XVw1eXHQ=; b=QI+OYWFey2knFXg/6TV3zWfXWgBA6brmw7vu1RU/4CAWjhqZp7obg2EW20gJGwpc9GeeiR BjiQ6iLeW1Nf2uLUC+LmUup/k7OP4CuglmpB/A64PFGbPvypykr7B/Zbim+NkC7W8xDVH1 PD2GBd1Mn6BNIxVPWwrA8xi/yDMhQ5U= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-315-dB9lZH7VNWyNeRxWmJ1cNA-1; Tue, 10 Sep 2024 15:16:16 -0400 X-MC-Unique: dB9lZH7VNWyNeRxWmJ1cNA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DDF491956069; Tue, 10 Sep 2024 19:16:10 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.22.17.222]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6DC0130001A1; Tue, 10 Sep 2024 19:16:03 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Huth , Cornelia Huck , Janosch Frank , Claudio Imbrenda , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Andrew Morton Subject: [PATCH v1 3/5] virtio-mem: s390x support Date: Tue, 10 Sep 2024 21:15:37 +0200 Message-ID: <20240910191541.2179655-4-david@redhat.com> In-Reply-To: <20240910191541.2179655-1-david@redhat.com> References: <20240910191541.2179655-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspam-User: X-Stat-Signature: n5gwyrci8xe4mnmq1k7wimfngpesiixs X-Rspamd-Queue-Id: 63737A000C X-Rspamd-Server: rspam02 X-HE-Tag: 1725995780-626089 X-HE-Meta: U2FsdGVkX1/tz2GqDtCEUOZ9TQGx3cJFpo+SOY/tAZny1zB3YXTPbzuQGwiVLE4QefU2WqYVg9POP1yp+adAjkZ1FzIYh8u0bXWKpvtfxqGUw93eYyKmJ8cKlDhtv478oAP/phh0uWHe93ij/lwIGUdeDeG+nsYemKdhi7GS2/Qm9i8evbENDLka0ze16rDNlvs5RQ50I27IuMzwQV+kkGbYuyH2KLzbRVEYgA5Hs3DmNyPEQAsk1tMVQ1YrrNb21k+5+kG9Wz8nyx4YL5rellGParIBzer80TdxgEM5wMKit977Ct/w8nA3XlqwAH8zzOn5PQ7uOX23ky9dUh4wka62kcCSSiVJTQeuL7w5BsLlvx0xcJQRd83v5s4A8QZdqumd16jO00UsQ7htYMFp1t0CkCEg69OMvR9WHBg0x1gcZblZqhhm0d9aV75r9anRTPvc09fOVx4Yiy9qteKEFYTnhcvt0eEOZcKDMbGh8q5+wbvXNlfOksc5bUz3hKxcVMwS73JvqBuLHBSugwhKKW6/DvBSXW1kBkyoCE/CURAI7Z/e3pW8kITyDmhCPgrXdBCGPwKxFq5Ofl1Odv6di3JIMUr+dWQAc4pa5W2PznS+krptm9RKEzMeSBY6OJAVRt7ECBjSkouguRcM9B3NAPWcFVdlTQY9HvDYrwk+1+c5TSyKS0dtfZxgP4Pfhqy3GQRLU9BHSQVbINRnUAK5rg0jGXmDQqITFN3YyDAk5nf/2jjDB5h3G+UIAb6imxyuSt1O8CZD1brp5pFNGQJ5eMPIX3U3DMarEplx6TPGu2mKCv+FohE6WzEf13e/U9O8bIo56Scg4OwclrBS3gkFYuTp812iYgEc2TVpQd1RbCqR5TIjCnJf0quSrdWtAhI2aVKlUa2HgUBOCPIl92yydN2H1SwAU/cXBkUszL94yESB8W/yrgDIYseZzc0XpBZvv/0gJ8tKfyh0AaCPtX9 yd8Pjb9D OVhcLSrUzrQ/QziEPLaznVqsg3rSKESb38sTQbSKouG7SvmKsP0XlZFe1/7ntVJKAXhZ15eqeqPzYlZO0o6BzxuszKecsgS5qw7cQN5O7dmCiNp57sjY3n62q2Rjch+ysXdu+NAbevGs4Vk4gNMH3gezoUqWx8j/JC48pWTLGF0JDY3Njtdm7NmMJ2oiIjlUHQWXzw5D8q/gz8TK/LJV5DenjQWRDG+MhfDDEnZsS4VnyIbQMpvgEkZbNX4hZd6+Bmym+u8VhjH0cyWg1FuQTRBtbB7+r8wVRauVloSgCCHLyVveJ3H96IWeu5VopNhPMu7ARsgKKLOrh4xM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Now that s390x code is prepared for memory devices that reside above the maximum storage increment exposed through SCLP, everything is in place to unlock virtio-mem support. As virtio-mem in Linux currently supports logically onlining/offlining memory in pageblock granularity, we have an effective hot(un)plug granularity of 1 MiB on s390x. As virito-mem adds/removes individual Linux memory blocks (256MB), we will currently never use gigantic pages in the identity mapping. It is worth noting that neither storage keys nor storage attributes (e.g., data / nodat) are touched when onlining memory blocks, which is good because we are not supposed to touch these parts for unplugged device blocks that are logically offline in Linux. We will currently never initialize storage keys for virtio-mem memory -- IOW, storage_key_init_range() is never called. It could be added in the future when plugging device blocks. But as that function essentially does nothing without modifying the code (changing PAGE_DEFAULT_ACC), that's just fine for now. kexec should work as intended and just like on other architectures that support virtio-mem: we will never place kexec binaries on virtio-mem memory, and never indicate virtio-mem memory to the 2nd kernel. The device driver in the 2nd kernel can simply reset the device -- turning all memory unplugged, to then start plugging memory and adding them to Linux, without causing trouble because the memory is already used elsewhere. The special s390x kdump mode, whereby the 2nd kernel creates the ELF core header, won't currently dump virtio-mem memory. The virtio-mem driver has a special kdump mode, from where we can detect memory ranges to dump. Based on this, support for dumping virtio-mem memory can be added in the future fairly easily. Signed-off-by: David Hildenbrand Acked-by: Michael S. Tsirkin --- drivers/virtio/Kconfig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig index 42a48ac763ee..fb320eea70fe 100644 --- a/drivers/virtio/Kconfig +++ b/drivers/virtio/Kconfig @@ -122,7 +122,7 @@ config VIRTIO_BALLOON config VIRTIO_MEM tristate "Virtio mem driver" - depends on X86_64 || ARM64 || RISCV + depends on X86_64 || ARM64 || RISCV || S390 depends on VIRTIO depends on MEMORY_HOTPLUG depends on MEMORY_HOTREMOVE @@ -132,11 +132,11 @@ config VIRTIO_MEM This driver provides access to virtio-mem paravirtualized memory devices, allowing to hotplug and hotunplug memory. - This driver currently only supports x86-64 and arm64. Although it - should compile on other architectures that implement memory - hot(un)plug, architecture-specific and/or common - code changes may be required for virtio-mem, kdump and kexec to work as - expected. + This driver currently supports x86-64, arm64, riscv and s390x. + Although it should compile on other architectures that implement + memory hot(un)plug, architecture-specific and/or common + code changes may be required for virtio-mem, kdump and kexec to + work as expected. If unsure, say M. From patchwork Tue Sep 10 19:15:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13799285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BC30EDE9AD for ; Tue, 10 Sep 2024 19:16:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 335B28D00A9; Tue, 10 Sep 2024 15:16:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E5F78D0002; Tue, 10 Sep 2024 15:16:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15E718D00A9; Tue, 10 Sep 2024 15:16:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E72A58D0002 for ; Tue, 10 Sep 2024 15:16:23 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9A359409B3 for ; Tue, 10 Sep 2024 19:16:23 +0000 (UTC) X-FDA: 82549784646.30.22EAC8B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id EF767100018 for ; Tue, 10 Sep 2024 19:16:21 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AeEKVmnG; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725995678; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5dwp1+ZWlakCCMbjLs+RuljQC2sU4OdCWLWut1FtVKY=; b=c1KAQKUGUhyqF+RRZ90Ru5heciYIC5BSARvxAdHn8s/9knr6zJPq9JgA2/4JqTZkXYoK6A +eO5UF+NKpDGgl9xVxBskrwviUFBcq7k/yKonb0ih7Cqvi/XnH4spnDDVWYSUjx583tGA2 pEZKgMUbhYJtd8HLdbZpTnxMvHn5xG0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725995678; a=rsa-sha256; cv=none; b=NNRvKQI+HSL7wbt7o2Hnp8+MWvs34WtZWcGkgGFMf07BV8C3d41VVCzRCMInhhW7tK/XSe oJ+bqGLwBDVwlzZATskPWOXhX98/1E4BheFongwFlMN8AHzgfLVPxBjXJcFairiEycRXnp RTyPTLJu+Aj0figNcC+9jvSWqMzlBKo= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AeEKVmnG; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725995781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5dwp1+ZWlakCCMbjLs+RuljQC2sU4OdCWLWut1FtVKY=; b=AeEKVmnG5HssL77rPvUa4egyndi3n54UxKNx+GSUzR7ZhHvaFLdIzY0Uw8u5JGVNKb6SJX 7K0PLflM2Pm24LT6r3TljaMMoFe9fYSjv1wKjsAZ8c/SI6l4UjveD460Uu6DLrwBx5/gq0 ImvnGyxtYTnmk5qY6kpX+ha2IWasyE4= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-221-xIwG_QIJM6al6Jomp-rQGQ-1; Tue, 10 Sep 2024 15:16:19 -0400 X-MC-Unique: xIwG_QIJM6al6Jomp-rQGQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 64853193E8EC; Tue, 10 Sep 2024 19:16:17 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.22.17.222]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6AF713001D0F; Tue, 10 Sep 2024 19:16:11 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Huth , Cornelia Huck , Janosch Frank , Claudio Imbrenda , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Andrew Morton Subject: [PATCH v1 4/5] lib/Kconfig.debug: default STRICT_DEVMEM to "y" on s390x Date: Tue, 10 Sep 2024 21:15:38 +0200 Message-ID: <20240910191541.2179655-5-david@redhat.com> In-Reply-To: <20240910191541.2179655-1-david@redhat.com> References: <20240910191541.2179655-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: EF767100018 X-Stat-Signature: 3ywtdhhqdq3x817dqz4y1y4jyow4rs19 X-HE-Tag: 1725995781-225091 X-HE-Meta: U2FsdGVkX1/SvPOe6k1kEsIHaj0gCBzDq6wG2iRXW4pd4ZtlY0SorhVtS+FJj3pDAtptXgn7Dyv8fblVagTOMjorBl+1hKVacVG4hpe9baxirTpV2AH9rwoE/fb9S98dX+eEK/ll2pu3vjio2+YtHHpwPfghv112HdvNyKOD3UwGLdS97ceDATy4KPOx01kkcy9mov1/2wLPfHMkgHRax46IddyOFVjzsunoj2qJTwB/ytFsE7VSHQ78CQcL7StalQ0Kwmfl8xJTXFIuRUIMpYAle4dAm1T6nSOcbLAz3jsWKyk834xAonTzJGMNsOTlA9DDxEP0utDovz/9Ue60zeJckR922LPdoXFuO3QVl89CJI7asn38mR39qmgkO3k9x25B8/CAfKensX5KAVUy9ABglgO8sC0jlCNrre4GtF5gQGfNhtEtb7zr6pi2P6aPE0NTv29lXDiHvPNurICiGXB/vCmjxv5UFwHcmhxiQdMVBJFha6UHcExGOWPb5lQX4PY7p/8n/IbdobaIsY5hhqEcfVRHB4Y4yjrksiyzAWcjNd7Q8gPSWUOQ/OdPLLC4fUSJM83D4FegZ4MVIYqGYRV3iajl5Un+3782uVQ+C1MgFFyR08MiWejvsTgVKQ63U7ZaIh5/wki9TVHvraxXHoA+W/dc7MMBErGLeKKcr2zce80f/E2KXA6/BVux7dPgQxnEL6vFlailMZDscaQ7BDwo2are6WYx+5p/RoThP4lPgPjNRy8NSyMfI0NrzRcfILba7SrHkqIOLT1LKvdL2lx+hVp0m1U4eQ6Uf0l18CETyENMXtTqkFC4E01JX31fjANWW5x0tdFnIwf528JdV0LdwFhbFaczUT6GEtMZd4q0ildz3WUzRmQBJAr9sL62ro6DeJbPZgmdfc1Tj1WyQ/SA98E3ghorVvyzL0IiSdSy7hM8Nyl8JAQCiaG1xX+PLP+2OPeN+Tm+XKMJPzt AWn60avY 7NRahrmE/xMAUJbJhTXtgNiTXhPgzz36Sch5uItE+luJq+Fr7Wzk0bIY8C5XSMqb7+gWGgK7ndOZhTaENRrKuLFvJJLsT1G7FlA1MFjwZzRYf5JZ2pdfGzS0eMs3ZyBgeccnWO91bnpYK9K9or+y9yMTWAtj3B8WtqAVuDvwTsQhlrrRFxd8lyujxclG4MOr4Zt1nQb77eDNjTiLW5rY1b6ApxJNFyrJZgpIKdICT8S67iAcGSDMhKp773yVe5Vxrgbd5ELmxBveUloVmc4Kiow6MaRQA0/JFEezrhTToxEGX1DhrOem7XD/biV2YBDbjvwy+xyBI2XgDzAbBGBo4BXj4U/UlvhqjhPhUZEmhX5Nt45MWn8gqR8cVxQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: virtio-mem currently depends on !DEVMEM | STRICT_DEVMEM. Let's default STRICT_DEVMEM to "y" just like we do for arm64 and x86. There could be ways in the future to filter access to virtio-mem device memory even without STRICT_DEVMEM, but for now let's just keep it simple. Signed-off-by: David Hildenbrand --- lib/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index a30c03a66172..fce22ce54983 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1887,7 +1887,7 @@ config STRICT_DEVMEM bool "Filter access to /dev/mem" depends on MMU && DEVMEM depends on ARCH_HAS_DEVMEM_IS_ALLOWED || GENERIC_LIB_DEVMEM_IS_ALLOWED - default y if PPC || X86 || ARM64 + default y if PPC || X86 || ARM64 || S390 help If this option is disabled, you allow userspace (root) access to all of memory, including kernel and userspace memory. Accidental From patchwork Tue Sep 10 19:15:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13799286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3CA7EDE9AD for ; Tue, 10 Sep 2024 19:16:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 706188D00AA; Tue, 10 Sep 2024 15:16:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B4FC8D0002; Tue, 10 Sep 2024 15:16:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57CE88D00AA; Tue, 10 Sep 2024 15:16:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3AD2F8D0002 for ; Tue, 10 Sep 2024 15:16:32 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B48F91A09B9 for ; Tue, 10 Sep 2024 19:16:31 +0000 (UTC) X-FDA: 82549784982.23.E130E2B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id F283180015 for ; Tue, 10 Sep 2024 19:16:29 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZWNM2C8T; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725995762; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xMATIjJHQHWxMji5r7WdDXGhstKkdxXCo0yMMstlfH8=; b=T/5jI8MG1dV1kaU4AOFQfj7k2JJpuvdlSrV9vIwVTCw6RY1tbtYSv4O4iZt2o1xqiBO8ia 8EKRabyA9dA9NmTpSYPoZF4D4bU6d6WWD56MUT7seZnoOyUAlB33XUAbjcBaTK00SUMXhF h5O/32QNOcstfUmc2W5dkWGrJ2RN78A= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZWNM2C8T; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725995762; a=rsa-sha256; cv=none; b=P6QnzCKx1Ij1SiFjDjNyl/47sdlCjrNfdwbhu6nSg8oV3tnV0UBLheH18svjlWQg6sKkJT aBKpGV5JoMF8X8I0UuBmRteiLO1PvJxggR4MvFlbBDEvldoKWmNQwHWonRftFVWcH/bnei UO1hv7WVUmwpohrOyzqPTbtrKaTWrqI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725995789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xMATIjJHQHWxMji5r7WdDXGhstKkdxXCo0yMMstlfH8=; b=ZWNM2C8TqQNfWEiN6cAHxi5RXzN0wAzkFUXVU8r4X1nfww6FCKYaqC3a5klH0YZBmKEMXr oFl+uurE40hGGzoy3U37iQTf/MDnNnmdBlP7hCMU1Kw0Ujg+rF61LMjiXlU67k3ot/RExz NHmqwX1RWVmZIs/CzMkl4EdD2mO385M= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-232-WbUGol_bMq2IBJu7l5Sszw-1; Tue, 10 Sep 2024 15:16:26 -0400 X-MC-Unique: WbUGol_bMq2IBJu7l5Sszw-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2C2851955BC1; Tue, 10 Sep 2024 19:16:24 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.22.17.222]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DF81B30001A1; Tue, 10 Sep 2024 19:16:17 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Huth , Cornelia Huck , Janosch Frank , Claudio Imbrenda , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Andrew Morton Subject: [PATCH v1 5/5] s390/sparsemem: reduce section size to 128 MiB Date: Tue, 10 Sep 2024 21:15:39 +0200 Message-ID: <20240910191541.2179655-6-david@redhat.com> In-Reply-To: <20240910191541.2179655-1-david@redhat.com> References: <20240910191541.2179655-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspam-User: X-Stat-Signature: idcdazj98d8zagh44y6xgcsrczfmaxtx X-Rspamd-Queue-Id: F283180015 X-Rspamd-Server: rspam11 X-HE-Tag: 1725995789-174013 X-HE-Meta: U2FsdGVkX18dFssjn9ajtfvgbLXfFCN2AQF2KKAbN1Zs7AYyq50E+snFSRXbxNFnVuTSOURHFyylcGEWls2Q/1nvbE8ErQmvd5wJrCeuImDTM87musN6alDgabdBipj4xza4HQbmK672/fHW4a4caxI9grMLW5H2R1Xo8ygTlZ1kgr/GU386JGzxsADG908WfAHu+++vtIF3qQaK+BE9hjX98diYjVjHiTeEihOM0+njCVINe5YIZwGNtt5ZMc427LdG6zHrwOipf7aF1ZK0bSJnylMchuc5YE3ZyqSCm1OGjQO7DAztY3jNiPOASYReznKlG36Q4Ct03oG4LYbJLbZqn1fmuRn3DXc0t3NqAK3d6qiD7o//Um8bFaUx/07P1bMBiuLMubQZH7Fyw0g3q1hHVW0MyItAcbuAGGNgGmkrQ/DUPimgcREjsfhx/3a8oeWuu2f7FKmScr1pp4O+IfBArfvbw28ThpvPR6dex5qd0L0H8v3arS0YTjKFC3MicyAHYIpe4ck9zgxrRFw7Y4SuAYcm63EEsSFfv3fS2HgXQzJiyvSgPQbuJGHcXxFGCmDUuYMiDKbI8KFJnFElavzLSEZamFjTUuFmyZ7FYy6rv0+XhOycHXvokCRErGgo+oMsJXJ5pyLlrGZbJLdMrcRTV89S4hUPXuB3TBwxQybt8p5aCw70cYsEpWeBzvvGig+VZMLh8F0Yg0axxUuQN5KUlSX62KHywirMN0hXviq7WC+TuVmOQ0B8cZBV4MybRZAZiwNo9P+Cv0Q6j32riEse01BaibODjvqjbXvuByyDlJO1yqqyJ7HksKjUTshIXbrb8AaN/9pcKor3QK44VgRID6P0tQvH7e+0ExGxcLCshi2QsdQiDTr5lEfQySNFFAtiTIbxeT5L78cD7TT7oBNbxFPg4Z/aGKwfJCixunwsgUNIMBZhVRUa4jMyLzuXQ7ImgMn/gud5KBB8/h6 ZOIu0bEk lEOcS6PgZjONA0W2Ofmz/KQRfaV+SqYjjO6/vsiJ6mlHfblXYx9PclVIyWKszii6AtENrgGL0S+91s1X5UiODKDowiWpvBGsvGtPVmCxptZ1QoxOQhZgH0xpONISzu2vZhpKeT8vztUW27w1w5MKi6191HIi7rmmfKjvWe5vZZNeVX5lJsk9uQ+hAx7Fenh+kkSfGegAdl5v7sHx4C9/4vKUJJ2nJCgp6nz5XYqROb+nLBKxC36Heb08dG3nI2Uk9gtphQzq8lcv9M6t55MUXKJtaIGISjX7oYmPcf2Ec3hXE5Fcszids4Dds+w1KciT8Ix+Mwtooo06a1vk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Ever since commit 421c175c4d609 ("[S390] Add support for memory hot-add.") we've been using a section size of 256 MiB on s390x and 32 MiB on s390. Before that, we were using a section size of 32 MiB on both architectures. Likely the reason was that we'd expect a storage increment size of 256 MiB under z/VM back then. As we didn't support memory blocks spanning multiple memory sections, we would have had to handle having multiple memory blocks for a single storage increment, which complicates things. Although that issue reappeared with even bigger storage increment sizes later, nowadays we have memory blocks that can span multiple memory sections and we avoid any such issue completely. Now that we have a new mechanism to expose additional memory to a VM -- virtio-mem -- reduce the section size to 128 MiB to allow for more flexibility and reduce the metadata overhead when dealing with hot(un)plug granularity smaller than 256 MiB. 128 MiB has been used by x86-64 since the very beginning. arm64 with 4k base pages switched to 128 MiB as well: it's just big enough on these architectures to allows for using a huge page (2 MiB) in the vmemmap in sane setups with sizeof(struct page) == 64 bytes and a huge page mapping in the direct mapping, while still allowing for small hot(un)plug granularity. For s390x, we could even switch to a 64 MiB section size, as our huge page size is 1 MiB: but the smaller the section size, the more sections we'll have to manage especially on bigger machines. Making it consistent with x86-64 and arm64 feels like te right thing for now. Note that the smallest memory hot(un)plug granularity is also limited by the memory block size, determined by extracting the memory increment size from SCLP. Under QEMU/KVM, implementing virtio-mem, we expose 0; therefore, we'll end up with a memory block size of 128 MiB with a 128 MiB section size. Signed-off-by: David Hildenbrand --- arch/s390/include/asm/sparsemem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/include/asm/sparsemem.h b/arch/s390/include/asm/sparsemem.h index c549893602ea..ff628c50afac 100644 --- a/arch/s390/include/asm/sparsemem.h +++ b/arch/s390/include/asm/sparsemem.h @@ -2,7 +2,7 @@ #ifndef _ASM_S390_SPARSEMEM_H #define _ASM_S390_SPARSEMEM_H -#define SECTION_SIZE_BITS 28 +#define SECTION_SIZE_BITS 27 #define MAX_PHYSMEM_BITS CONFIG_MAX_PHYSMEM_BITS #endif /* _ASM_S390_SPARSEMEM_H */