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 X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DACCFC433FE for ; Tue, 8 Dec 2020 16:42:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D7D923A53 for ; Tue, 8 Dec 2020 16:42:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D7D923A53 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.47597.84235 (Exim 4.92) (envelope-from ) id 1kmg3z-0000jo-G2; Tue, 08 Dec 2020 16:42:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 47597.84235; Tue, 08 Dec 2020 16:42:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kmg3z-0000jh-D4; Tue, 08 Dec 2020 16:42:07 +0000 Received: by outflank-mailman (input) for mailman id 47597; Tue, 08 Dec 2020 16:42:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kmg3y-0000jc-8E for xen-devel@lists.xenproject.org; Tue, 08 Dec 2020 16:42:06 +0000 Received: from mail-lf1-x144.google.com (unknown [2a00:1450:4864:20::144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 70c061bf-f533-49cd-b338-2897a66bf768; Tue, 08 Dec 2020 16:42:04 +0000 (UTC) Received: by mail-lf1-x144.google.com with SMTP id 23so11520772lfg.10 for ; Tue, 08 Dec 2020 08:42:04 -0800 (PST) Received: from [192.168.1.7] ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id p7sm3247086lfc.222.2020.12.08.08.42.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Dec 2020 08:42:02 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 70c061bf-f533-49cd-b338-2897a66bf768 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=nO71H+lpySIUCevPMYEFO+2WdKIK4v2yLo3yenusKsI=; b=u9g1memofRM4rP0x8qj+jkgGHT98+CW6/6fBYFXVrZL3ZyrLAZTdtDnQ+MPUSQdwlL E79lrh41F16XqZlO0g7d9HxMJfHMlaK0dPN7tlk0WszgB6IVn1IC3HQ2tVko8Qj6bxuA 26gyRB0cGyG9ttfU41gT0Pahvgu1YAObjNK9moS88v34oWIB3qS/6guAVGq1fugqksrQ ThO4gJJ3YZusE61l0xLSVTkbkuI1geOe6tQ9Tv10CSz3xjlASyfCw3q4NG/ZLaVjxteT u4C5ckktZ5MJHxkpSS3Mi2u4/G1ze0R77SxWTc5u2rQqvLsr2AZJTqPxH8dcdePS83Qw 0pmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=nO71H+lpySIUCevPMYEFO+2WdKIK4v2yLo3yenusKsI=; b=JxVYuTUX5Ii0SwveykXGFv7ahx2xsXMJouOhUzaxZSC1CvQBY/VhmP3Zjfb7HmEI2b dlelI1PQEQ/f0FOw6t7s4gaK/+LA0fYXtxbw+Dl953qh5dKwmWH0dlWpr5m7p1xdJ6nv gSW7cRksc3ZsZTK9PQDY9VOBPt6a3xm86n2c+V/DcziIU4facnSZc+qqsvnXk6UX0Zm4 M72wEtBtshcASQ6cm03t3no+clciUnKE7/7p3CGgZq9ga4AkXt5P7q4QpHs5YwEPkuJW aefSFh4SiwbssbWZsFz6nT7mwFlackgnvGrMzpZb8OJUZFBRLY2sbPWUB3NaoDqNEaV8 Zrzw== X-Gm-Message-State: AOAM531+fReCS8+s47ABl4l8S5i2oG8x8pZuV1Xfap5cOexa5vBZAI5Z EfJI7by2pYj6EnbiTodveoEJTPaaIs7Y7A== X-Google-Smtp-Source: ABdhPJw5GJO50ncmK487CxnIrSV2Ad38z4Vka40SPmGgWSo9SALdAfAtX6HVl7zMQaFQcmx55wuELg== X-Received: by 2002:ac2:5a49:: with SMTP id r9mr10512099lfn.381.1607445723569; Tue, 08 Dec 2020 08:42:03 -0800 (PST) Subject: Re: [PATCH V3 16/23] xen/mm: Handle properly reference in set_foreign_p2m_entry() on Arm To: Jan Beulich Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Ian Jackson , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Julien Grall , xen-devel@lists.xenproject.org References: <1606732298-22107-1-git-send-email-olekstysh@gmail.com> <1606732298-22107-17-git-send-email-olekstysh@gmail.com> <5f1a2914-f894-0046-2911-9cccb5d94dbf@suse.com> From: Oleksandr Message-ID: Date: Tue, 8 Dec 2020 18:41:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <5f1a2914-f894-0046-2911-9cccb5d94dbf@suse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US On 08.12.20 16:24, Jan Beulich wrote: Hi Jan > On 30.11.2020 11:31, Oleksandr Tyshchenko wrote: >> --- a/xen/common/memory.c >> +++ b/xen/common/memory.c >> @@ -1134,12 +1134,8 @@ static int acquire_resource( >> xen_pfn_t mfn_list[32]; >> int rc; >> >> - /* >> - * FIXME: Until foreign pages inserted into the P2M are properly >> - * reference counted, it is unsafe to allow mapping of >> - * resource pages unless the caller is the hardware domain. >> - */ >> - if ( paging_mode_translate(currd) && !is_hardware_domain(currd) ) >> + if ( paging_mode_translate(currd) && !is_hardware_domain(currd) && >> + !arch_acquire_resource_check() ) >> return -EACCES; > Looks like I didn't express myself clearly enough when replying > to v2, by saying "as both prior parts of the condition should be > needed only on the x86 side, and there (for PV) there's no p2m > involved in the refcounting". While one may debate whether the > hwdom check may remain here, the "translated" one definitely > should move into the x86 hook. This (I think) will the also make > apparent that ... > >> --- a/xen/include/asm-x86/p2m.h >> +++ b/xen/include/asm-x86/p2m.h >> @@ -382,6 +382,19 @@ struct p2m_domain { >> #endif >> #include >> >> +static inline bool arch_acquire_resource_check(void) >> +{ >> + /* >> + * The reference counting of foreign entries in set_foreign_p2m_entry() >> + * is not supported on x86. >> + * >> + * FIXME: Until foreign pages inserted into the P2M are properly >> + * reference counted, it is unsafe to allow mapping of >> + * resource pages unless the caller is the hardware domain. >> + */ >> + return false; >> +} > ... the initial part of the comment is true only for translated > domains. The reference to hwdom in the latter part of the comment > (which merely gets moved here) is a good indication that the > hwdom check also wants moving here. In turn the check at the top > of p2m_add_foreign() should imo then also use this new function, > instead of effectively open-coding it (with a similar comment). > And x86's set_foreign_p2m_entry() may want to gain > > ASSERT(arch_acquire_resource_check(d)); > > perhaps alongside the same ASSERT() you add to the Arm variant. Well, will do. I was about to mention, that new function wanted to gain domain as parameter, but noticed you had given a hint in the ASSERT example. -- Regards, Oleksandr Tyshchenko