Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3678215imm; Tue, 29 May 2018 11:25:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZokQsUCKHrsCD25AWbhYIAcymtbMBh7ziiEB3ru5DyF7co6PHsLqKsYX2wbwB76a9DsMGqK X-Received: by 2002:a65:534d:: with SMTP id w13-v6mr14427982pgr.178.1527618354707; Tue, 29 May 2018 11:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527618354; cv=none; d=google.com; s=arc-20160816; b=0Ewb2WgI/nBS/Je2LNbMUZjAhc8F4fI9NTzro3lF1M2mK+3gJdmVwEFHP1qXb2HEwl IRwjALEIyBELFfboQhg2zIo+CwkwUyWh1Lt4NVXJNFRg09N4o/kplTLx23toB22pSwyQ IQCPUy8Ssy1NA9iR2pnOrKpA1OiD2johXaU/IfSFXNcHahOosng2wRCT9zBk349BCC6V XoGxuUSPgAqYKYx2SrPyXQdn2hHPs0DuEj0iy5lG01ztHkG0qXJH44CJs/o96BSqDZbS TIUvzvr9RVUkiSTaewwSQn4/H5oPNXPHM3/ft8dm1a8skyidh00cmorExCPcVloHFrpk 0VUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=FykMeuXdHFO+Bwm247/QkqbVyAiw3hHW3W5fw3iVnoc=; b=JVA/iG9UlbWbAqY97jLnunNTB8GK2FBAspIynHkhWSWW2wBJTtbWx7jxHgWXWsJF1o 5aoCFgb3Lx8YymShYn1kPjtgacknAMSny/PGq7SnAKNijwjmqCwxyva2zYJSQOPstPI1 0QUiPb74lsUmYtXzoJJ9rNAnjRcCPeobfB5jlfoqSrCPt2oLcCsQTLEXHxVpx+H+8b3y oegM0Zfdc6TkMj9tqChqRxNTO3P6mCoKhGEnQBqLczKJilD5BZa9ec4aRhCa1mNxaQA7 N+FTSzOH6NaLZFq2DDls7ocbmTVC34QPOHy+kuGu5ioZLVUGELe8Y1OaYFvlkraCvD3Y YYdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L3DsfYGs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id u30-v6si5712011pgo.678.2018.05.29.11.25.40; Tue, 29 May 2018 11:25:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L3DsfYGs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S966297AbeE2SXc (ORCPT + 99 others); Tue, 29 May 2018 14:23:32 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:43296 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965752AbeE2SXZ (ORCPT ); Tue, 29 May 2018 14:23:25 -0400 Received: by mail-lf0-f68.google.com with SMTP id n18-v6so227845lfh.10; Tue, 29 May 2018 11:23:24 -0700 (PDT) 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=FykMeuXdHFO+Bwm247/QkqbVyAiw3hHW3W5fw3iVnoc=; b=L3DsfYGsG/dLsC8/YDeEEaFuGluFlt2AHdc0NUYqMYcDsF07HYvc8r5mcYoTE7q62m p+AuYCzIXzSE0SeAuyfdEE5ywBpu1V+5yZmfHVTV9sIzohs0sveftiM3I+G5SWcb9ZuQ Kt+eLc0y3KmjdES9JrHsdAgCY9XajKeOFcV5383kIEbZB/w6dQgpOkReUM55NFtJmVmc JlPb03tqtGerV0Un/6ObEJ/5q39G/DizCDaAYAF+R71fB3OdTGw6sEZyeohOPS2ya5DR 8kmJiNyulVCytd9HJtSoU7XM6oaa+rYQ3nI5Tdn5YdZbQ3AYkkawx4HRRkRJry/6qrKQ P/vQ== 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=FykMeuXdHFO+Bwm247/QkqbVyAiw3hHW3W5fw3iVnoc=; b=mM/vzABMPXxfkCg+kL1LhDhHKGynb98/aGZkDA2H1zt6cQ8DVFISpT+pS0xtiS8eMv QZ6dAFIrkUHaAmpmDwE45+5uzS42OeSOTopuNVW4joiWp+G1kUiASETJbdXry4SKnz9Y MPhuUBc6x/7tMomw6tjvrCxdXGDhrDq7200oQG2udxFTSlhW6KmkrQz9xPBnpy7oahgT GPN9xVmTzvHDOo6LDAAH9it0Uzyq3kDegHfWuYGloc/Gl5BGokRVKhYkWnMpXSRSxwFs NO1tKOYsfox+71aH2jCdClPLq53Bj+aeKJ00NMWiJFaFb8ygIDrj2I0i7Mc8+48hrrKR 2lHg== X-Gm-Message-State: ALKqPwdevHhHtZsfjbW0odhfgudiq7EUZ/R7+CLhZmg6h2YdLHcQqfGn NJD3/7AbeQhoG2rfChFPh/lD5Dx1 X-Received: by 2002:a2e:9911:: with SMTP id v17-v6mr11907097lji.57.1527618203456; Tue, 29 May 2018 11:23:23 -0700 (PDT) Received: from [192.168.0.20] (192-39-94-178.pool.ukrtel.net. [178.94.39.192]) by smtp.googlemail.com with ESMTPSA id u8-v6sm6680768ljg.40.2018.05.29.11.23.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 11:23:22 -0700 (PDT) Subject: Re: [PATCH 2/8] xen/balloon: Move common memory reservation routines to a module To: Boris Ostrovsky , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, jgross@suse.com, konrad.wilk@oracle.com Cc: daniel.vetter@intel.com, dongwon.kim@intel.com, matthew.d.roper@intel.com, Oleksandr Andrushchenko References: <20180525153331.31188-1-andr2000@gmail.com> <20180525153331.31188-3-andr2000@gmail.com> <44f62fb1-e013-2883-dfa1-386c7a96784b@oracle.com> From: Oleksandr Andrushchenko Message-ID: Date: Tue, 29 May 2018 21:23:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <44f62fb1-e013-2883-dfa1-386c7a96784b@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/29/2018 09:24 PM, Boris Ostrovsky wrote: > On 05/25/2018 11:33 AM, Oleksandr Andrushchenko wrote: >> + >> +void xenmem_reservation_va_mapping_update(unsigned long count, >> + struct page **pages, >> + xen_pfn_t *frames) >> +{ >> +#ifdef CONFIG_XEN_HAVE_PVMMU >> + int i; >> + >> + for (i = 0; i < count; i++) { >> + struct page *page; >> + >> + page = pages[i]; >> + BUG_ON(page == NULL); >> + >> + /* >> + * We don't support PV MMU when Linux and Xen is using >> + * different page granularity. >> + */ >> + BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE); >> + >> + if (!xen_feature(XENFEAT_auto_translated_physmap)) { >> + unsigned long pfn = page_to_pfn(page); >> + >> + set_phys_to_machine(pfn, frames[i]); >> + >> + /* Link back into the page tables if not highmem. */ >> + if (!PageHighMem(page)) { >> + int ret; >> + >> + ret = HYPERVISOR_update_va_mapping( >> + (unsigned long)__va(pfn << PAGE_SHIFT), >> + mfn_pte(frames[i], PAGE_KERNEL), >> + 0); >> + BUG_ON(ret); >> + } >> + } >> + } >> +#endif >> +} >> +EXPORT_SYMBOL(xenmem_reservation_va_mapping_update); >> + >> +void xenmem_reservation_va_mapping_reset(unsigned long count, >> + struct page **pages) >> +{ >> +#ifdef CONFIG_XEN_HAVE_PVMMU >> + int i; >> + >> + for (i = 0; i < count; i++) { >> + /* >> + * We don't support PV MMU when Linux and Xen is using >> + * different page granularity. >> + */ >> + BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE); >> + >> + if (!xen_feature(XENFEAT_auto_translated_physmap)) { >> + struct page *page = pages[i]; >> + unsigned long pfn = page_to_pfn(page); >> + >> + if (!PageHighMem(page)) { >> + int ret; >> + >> + ret = HYPERVISOR_update_va_mapping( >> + (unsigned long)__va(pfn << PAGE_SHIFT), >> + __pte_ma(0), 0); >> + BUG_ON(ret); >> + } >> + __set_phys_to_machine(pfn, INVALID_P2M_ENTRY); >> + } >> + } >> +#endif >> +} >> +EXPORT_SYMBOL(xenmem_reservation_va_mapping_reset); > One other thing I noticed --- both of these can be declared as NOPs in > the header file if !CONFIG_XEN_HAVE_PVMMU. Will rework it to be NOp for !CONFIG_XEN_HAVE_PVMMU > -boris