From patchwork Tue Jul 21 01:41:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 11674833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D94D2913 for ; Tue, 21 Jul 2020 01:42:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C28DE207DD for ; Tue, 21 Jul 2020 01:42:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZplvFcBM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728425AbgGUBml (ORCPT ); Mon, 20 Jul 2020 21:42:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728114AbgGUBmD (ORCPT ); Mon, 20 Jul 2020 21:42:03 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40D12C061794; Mon, 20 Jul 2020 18:42:03 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id g13so15033175qtv.8; Mon, 20 Jul 2020 18:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J3OHNM9zOYfQV2dG1GUcbEevN0jecbySISLynxXJOhc=; b=ZplvFcBMRUhUdrfEbS+kLjhrAFP/cazjPwN7eLIJFcrP7U38pyrgYOmcG8DUgznpHL 75/vFLnHFUaGEvXs2YhjW21fOpn/XsFCyWaSxwlPq4+72xUQb/rygDhs1ERSVjXboqdC AwPMM4EoQoHxeriYgQFE3ffQBZOxuVweyHdrSLhNsT+epQX2I7ANVjFuwUnjN/alPKAl LyHIQQ60EJh195yPDngyvTSy4KW/kM4JRVRvYmZ6VcdDiS1nXCYbxpmiilfXgDTbXJws UXuJalzLHWR0IW+/eSbNGg22xGCgeu63OD8XwIAS+3Ul5IHnFT+KtGMItdtB8/37ZWKt Nnvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J3OHNM9zOYfQV2dG1GUcbEevN0jecbySISLynxXJOhc=; b=hEiochWEGB5OCtE+gdOQA6ZdpCZ8kYLxRvOvrpBk6LGszO65Cii57i/v44M+t51JpO 3OJNn6ynJBXHelX0IwW6N1RlyV8v1ho0GJnMH8EoN2xcL0ddtYUNZeU4O2iV1wtnZcUC v4SPg8aDRlWbNPFT0dV24I8rUMjdOrpPsmuSn00s760Tv9h8Cuo3YqVl0kwBoUPLu0bP hJMckplvWjUWIEHoDg1ztBmbaa2TA0rIea0tyTe9sHw0wHXZ3O6jKSxremk7uG1iB+Sq q5QDrVcCv8pvELjtpzWJE3HgJdluRMDMbMv6kLfA0flerNsIkUZoV/7G4DghXax48U7X EFmw== X-Gm-Message-State: AOAM533vtFPMVZ5npRREfYU6UOPN2as2crxdg7vMkn+N+g4pZGtpc9d/ RdcHu/COstAvzqvGU1LbO/E= X-Google-Smtp-Source: ABdhPJzzPpsaFzrLMFbqT9vsoHMAK7a9Inlgzyrf05eKs8xDqZwxojFn5V1GU7KPnE9MmCCSmImQTQ== X-Received: by 2002:ac8:7a9a:: with SMTP id x26mr26409510qtr.161.1595295722576; Mon, 20 Jul 2020 18:42:02 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id d8sm1270243qkl.118.2020.07.20.18.42.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jul 2020 18:42:02 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 6D62627C0054; Mon, 20 Jul 2020 21:42:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 20 Jul 2020 21:42:01 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrgeehgdegjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenog fuohhrthgvugftvggtihhpvdculdegtddmnecujfgurhephffvufffkffojghfggfgsedt keertdertddtnecuhfhrohhmpeeuohhquhhnucfhvghnghcuoegsohhquhhnrdhfvghngh esghhmrghilhdrtghomheqnecuggftrfgrthhtvghrnhephedvveetfefgiedutedtfeev vddvleekjeeuffffleeguefhhfejteekieeuueelnecukfhppeehvddrudehhedrudduud drjedunecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomhep sghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtie egqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhi gihmvgdrnhgrmhgv X-ME-Proxy: Received: from localhost (unknown [52.155.111.71]) by mail.messagingengine.com (Postfix) with ESMTPA id DF1C93280059; Mon, 20 Jul 2020 21:42:00 -0400 (EDT) From: Boqun Feng To: linux-hyperv@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org Cc: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Jiri Kosina , Benjamin Tissoires , Dmitry Torokhov , "David S. Miller" , Jakub Kicinski , "James E.J. Bottomley" , "Martin K. Petersen" , Michael Kelley , Boqun Feng Subject: [RFC 06/11] hv: hyperv.h: Introduce some hvpfn helper functions Date: Tue, 21 Jul 2020 09:41:30 +0800 Message-Id: <20200721014135.84140-7-boqun.feng@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200721014135.84140-1-boqun.feng@gmail.com> References: <20200721014135.84140-1-boqun.feng@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org When a guest communicate with the hypervisor, it must use HV_HYP_PAGE to calculate PFN, so introduce a few hvpfn helper functions as the counterpart of the page helper functions. This is the preparation for supporting guest whose PAGE_SIZE is not 4k. Signed-off-by: Boqun Feng --- include/linux/hyperv.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index eda8e5f9a49d..b34d94b1f659 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1703,4 +1703,8 @@ static inline unsigned long virt_to_hvpfn(void *addr) return paddr >> HV_HYP_PAGE_SHIFT; } +#define offset_in_hvpage(ptr) ((unsigned long)(ptr) & ~HV_HYP_PAGE_MASK) +#define HVPFN_UP(x) (((x) + HV_HYP_PAGE_SIZE-1) >> HV_HYP_PAGE_SHIFT) +#define page_to_hvpfn(page) ((page_to_pfn(page) << PAGE_SHIFT) >> HV_HYP_PAGE_SHIFT) + #endif /* _HYPERV_H */