From patchwork Mon Oct 14 14:46:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13835144 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 376D0D16279 for ; Mon, 14 Oct 2024 14:47:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFB626B0099; Mon, 14 Oct 2024 10:47:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B83726B009A; Mon, 14 Oct 2024 10:47:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FDF46B009B; Mon, 14 Oct 2024 10:47:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7C0826B0099 for ; Mon, 14 Oct 2024 10:47:18 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CEAAEC0CC4 for ; Mon, 14 Oct 2024 14:47:09 +0000 (UTC) X-FDA: 82672485588.22.61B24CE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 4F10CC001A for ; Mon, 14 Oct 2024 14:47:10 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="H/fnZ6UH"; spf=pass (imf28.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=1728917164; 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=eNutO1hsgpqcUEbfHgtLFq1UOgF2cMswuycNM8rERoo=; b=hCqB2/WCWzwsFXE3kMhhG5iU1Ao99UWj0iA0aYH9XR6jwDd/JQ1rOM2J/fN4c42U5kc3Oi S7a3BvP7ckhN+q6cjfVT5KkBmx3jSETnx1pUxHA3EeldKWU56qY8xVepBVpOXZn1gFNp9w f4jrOfPfzwdqf5rMAPYHZps8ILywO6A= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="H/fnZ6UH"; spf=pass (imf28.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728917164; a=rsa-sha256; cv=none; b=LNW4tM0gNPiPRSAjAPBCPg0JsU+ylSFUFJzjXHaVCdmIAP6+F2Zo+4SbNFNcH0XIhuJA6h HbFxUI8Pf/IufEp/XvtiSgiBghsP7ICZJstVc+R3LoippaS0eMi9uycqZNiwfZZtY/B1VX 8FwfmlyyFo3mzM/uz6SYFM4mVuFRfg8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728917235; 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=eNutO1hsgpqcUEbfHgtLFq1UOgF2cMswuycNM8rERoo=; b=H/fnZ6UHwACmvgJw2lIbfxKBLtPvCj4PEiFuWKhetno7u5RNNyD0vFPtcMcF+DhApSC9rr SUDOyEm0+4eKsYD+oV65gJA0QKZNmH/9n7MP3kiBwO2W/s6uAx3WTYwZPQJpcWPXlHuAk6 IUnK+ePlN4uUCFDLkQ841gaSw/xsWGA= 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-387-aFyz8o1aOxaBv2Y6jRkjlg-1; Mon, 14 Oct 2024 10:47:12 -0400 X-MC-Unique: aFyz8o1aOxaBv2Y6jRkjlg-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 E358A195608B; Mon, 14 Oct 2024 14:47:09 +0000 (UTC) Received: from t14s.cit.tum.de (unknown [10.22.32.146]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B54F31955E93; Mon, 14 Oct 2024 14:47:02 +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, linux-doc@vger.kernel.org, kvm@vger.kernel.org, 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 , Jonathan Corbet , Mario Casquero Subject: [PATCH v2 5/7] virtio-mem: s390 support Date: Mon, 14 Oct 2024 16:46:17 +0200 Message-ID: <20241014144622.876731-6-david@redhat.com> In-Reply-To: <20241014144622.876731-1-david@redhat.com> References: <20241014144622.876731-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 4F10CC001A X-Stat-Signature: zgqpeib5dinyjyirpzqrtfrqz7wwfbkb X-HE-Tag: 1728917230-885089 X-HE-Meta: U2FsdGVkX1/VSoYE5MswDTXeIv/HPBNj66moUdSq0wG4MYnjbunODqO/Fbb2IIbTtb8OUVuWBZFpu5Ky6cJzi0ywsBlh9Xef0vBXEVcvXD79hNKB6VOkdNJNMel3ixeJ+r6ZygAEgu394ZynHy+Dm+263veeGHhbCQM7KIllQq02JpyY32Prft+57aKaqFyhO4PIgy5p5Y2R6Trq860LYcCNyXo/33gQxPRj4CCLPqloZV4C5sAonsNKzMHjEWp5wKtlrOtLnZ5FCADlYKzO5VYUWAetOtkrV8A7vjGt1uXp9cgzZ/RRw12xZI6i2t/bYeL7LE21IKLTl6smiByXZK7HlL502LpNy8lP5ZolNgqOcHJERytwMmldXxlthbfnhHJbuRUPl7a2QQWb5r296fq5oaX4WHt5WTi15Sr6MfpIYUcbNiUv6kcvPAE9Wr2vsY4usZ77ffeHr03eKEu0gHN+tNwKbMtOQwHyfEiY2i5SBGfHcuTPQ+CpAVGfXZM/BlD512LGagXpuhbmk4mjvu6ADPyT4HHpQvc+3/doTptAWjrlVot/D9u8A+eKpDhwDI6RY5VD6omS2lwAzxLAaOcE+hsozxNE/+Kw+iDNrMzw/78P5ktgMkWXSif+ZZKi3IfoH72aqfpaZ0n1JU/PtFsGPywVonXy5V+LsaHE73yfAZsabB0xCRf+Ix0FC95+9qKybfFJvnLPRXi8jAtEb1rX9VTKa7eq9Uo329QY7qgXOlMKyr00OYPXxVKRqgKJ3AJzvPig7jfCLdIUtrBR9I+zPFnhCGFD2K/e+v0+5kyT7r9wOOA2D5N5cXFfEkmFAH1cYLZ2b9p4KZP91aktUvMoX5REIXU06uLtxJTHCjyJrtprLFHB1VdjEEiJh0HfSk2bKPY2QYvhSdffTuwVFEbdWpy70Q6J9WIIGYKBNveb2WTu8lnfpwaaksIEB9oy3AGcyqgu/Njyxepz+5c Y5V1gvxi ZCYQVEVT+PA6+oZEQQkEhc0JyIn/fdI9foDJSy7CvXbssIl8tbnEDyxaIZs3tzk/6ugKb/VQU47s55NqQWwju/6EveOGgOFcACo8NQzx6LooPvHDTGQNaRPovkAnmTMKkzyXUvmyzmyNL7TdkgA5IxAj/8LQ/X8ptXDJZOhg34qzOkx+7xkGiXJHPeOxMJfXM0bbuVwH8rQ1LIIgqlle6czBwMujtMLngWefE8N6hN8GKhWtmXc8Q6NC4eIvT2ENCXaNkuc30eb1c5cjX4y8FR1ss0Wr4EkZFCevwQjRVdQZpvPXXVCdv9m9hU9BYhifvn4SGMSC9G4YvRc8= 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 s390 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 s390. 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 s390 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. Acked-by: Michael S. Tsirkin Tested-by: Mario Casquero Signed-off-by: David Hildenbrand --- 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.