From mboxrd@z Thu Jan 1 00:00:00 1970 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 025FBC433EF for ; Mon, 2 May 2022 17:38:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C3A86B0071; Mon, 2 May 2022 13:38:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7980F6B0073; Mon, 2 May 2022 13:38:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6132D6B0074; Mon, 2 May 2022 13:38:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 505C06B0071 for ; Mon, 2 May 2022 13:38:36 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 2F39880DE5 for ; Mon, 2 May 2022 17:38:36 +0000 (UTC) X-FDA: 79421512632.03.ABE9025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 92AA520079 for ; Mon, 2 May 2022 17:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651513114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2lunMsoGDoPigmLp9WsdCktYWSZoBwxRyUbwQafL3oc=; b=HgVRonWzD3sr/C/WMb97GyA2yBKAGMMTnscoPvJ5ABNeRWsdQROlo2y/H9p1KxXyk1D6xt p8e7MWpWqDzmH76mPOJGKDLqRDm4R3gqCDUTdWQSutNP1tDvDt7uwnajtQiQBS5XLrvLD2 4fJFu364kz4qR55gPkGN5AY2ULL3e4k= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-449-fm1scbhoNGmnfBxLoGppuw-1; Mon, 02 May 2022 13:38:31 -0400 X-MC-Unique: fm1scbhoNGmnfBxLoGppuw-1 Received: by mail-ot1-f69.google.com with SMTP id d6-20020a9d51c6000000b0060621097166so1196013oth.16 for ; Mon, 02 May 2022 10:38:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=2lunMsoGDoPigmLp9WsdCktYWSZoBwxRyUbwQafL3oc=; b=1Ie4cpiE+OxkVISguN6NBvEanCxh9rQ71JcEZXuohQuSoOp813TBodBK/YdtKEAAWQ 7rjhPK5PIx5/R4HJ0+mIBbrpzFo/l2aK1Zqow5ENmBSNHE+fxvBG9M9nBez0EEvSWdNe ma6Bf0E8jGuKwm+Y8ulST64/PN4XLGnahkdy/rb0jLJXvYV+zhc4RsgDTJS89NrAruLz ngehyV5HL/T0fC2Xuvs+iLlWUW8E64oN7k//D8W+JV3OPEmPrpZEtC0t0asTqc7DqpsR kSwXfvoTnlr4b3piA58Sz1xJUcWXIj34u2GtIlNQdCpclD8/7ZhyRjFlVNESYEPmaCn9 mVbg== X-Gm-Message-State: AOAM531j9xztoz5AQmR3SFChBgyBv7UtNYan06E/ZWoOjvftizFjubN1 hdzX96Lx10W3lb48Vt/QeIoSiUOpvqOuYyJsEZCimVLXrEJ5Noy+DEG3ixRUZEQF4vggW/bjH4u ZxhzfLyf5IIk= X-Received: by 2002:a05:6808:200b:b0:326:26c:ce59 with SMTP id q11-20020a056808200b00b00326026cce59mr109650oiw.179.1651513111203; Mon, 02 May 2022 10:38:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRGRGPdt8OhXkPLBIpSoSxrZC974z5CZa47w92aD7jl7n3XjRMqxULNt3/dHyq3nKIfkv6kA== X-Received: by 2002:a05:6808:200b:b0:326:26c:ce59 with SMTP id q11-20020a056808200b00b00326026cce59mr109631oiw.179.1651513110927; Mon, 02 May 2022 10:38:30 -0700 (PDT) Received: from [10.10.69.234] ([8.34.116.185]) by smtp.gmail.com with ESMTPSA id f9-20020a05680807c900b00325cda1ffabsm2515305oij.42.2022.05.02.10.38.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 May 2022 10:38:29 -0700 (PDT) Message-ID: Date: Mon, 2 May 2022 19:38:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [RFC] Expose a memory poison detector ioctl to user space. To: Jue Wang Cc: Dave Hansen , Naoya Horiguchi , Tony Luck , Dave Hansen , Jiaqi Yan , Greg Thelen , Mina Almasry , linux-mm@kvack.org, Sean Christopherson References: <20220425163451.3818838-1-juew@google.com> <5a7f00e3-311d-b5ca-4249-7f50f8712559@intel.com> <2b1d3a10-4a23-3787-dcfa-44f05554688c@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 92AA520079 X-Stat-Signature: w5oh6j1exmomihsiucb4e78hg9c69qa3 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HgVRonWz; spf=none (imf13.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam09 X-HE-Tag: 1651513104-485623 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: On 02.05.22 19:36, Jue Wang wrote: > On Mon, May 2, 2022 at 10:33 AM David Hildenbrand wrote: >> >> On 02.05.22 19:30, Jue Wang wrote: >>> On Mon, May 2, 2022 at 10:19 AM David Hildenbrand wrote: >>>> >>>> On 26.04.22 21:39, Dave Hansen wrote: >>>>> On 4/26/22 12:23, Jue Wang wrote: >>>>>> On Tue, Apr 26, 2022 at 11:18 AM Dave Hansen wrote: >>>>>>> What if you're in a normal (non-TDX) guest and some of the physical >>>>>>> address space has been ballooned away? >>>>>> >>>>>> Accessing to memory that gets ballooned away will cause extra EPT >>>>>> violations and have the memory faulted in on the host side, which is >>>>>> transparent to the guest. >>>>> >>>>> Yeah, but it completely subverts the whole purpose of ballooning. In >>>>> other words, this is for all intents and purposes also mutually >>>>> exclusive with ballooning. >>>> >>>> Some balloon (or balloon-like) implementations don't support reading >>>> memory that's mapped into the direct map. For example, with never >>>> virtio-mem devices in the hypervisor, reading unplugged memory can >>>> result in undefined behavior (in the worst case, you'll get your VM zapped). >>>> >>>> Reading random physical memory ranges without further checks is a very >>>> bad idea. There are more corner cases, that we e.g., exclude when >>>> reading /proc/kcore. >>>> >>>> Take a look at read_kcore() KCORE_RAM case, where we e.g., exclude >>>> reading PageOffline(), is_page_hwpoison() and !pfn_is_ram(). Unaccepted >>>> memory might be another case we want to exclude there in the future. >>>> >>>> >>>> I assume something as you imagine could be implemented in user space >>>> just by relying on /proc/iomem and /proc/kcore right now in an unsafe >>>> way. So you might want something similar, however, obviously without >>>> exporting page content to user space and requiring root permissions. >>> >>> Thanks. >>> >>> Are the following cases benign if the scan only happens on the host side? >>> >>> . virtio-mem - unplugged memory >>> . Unaccepted memory >> >> No, only in virtualized worlds. >> >> I assume GART memory that implements the pfn_is_ram() callback is around >> on physical machines. > > I think host E820 provides an accurate view of which address range is > ram or not? On most physical machines maybe to some degree. It doesn't hold for physically hot(un)plugged memory and I remember GART memory is special. No idea how that is exposed in e820. -- Thanks, David / dhildenb