From nobody Fri May 3 11:10:19 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563469966; cv=none; d=zoho.com; s=zohoarc; b=KJF8pOi80uweBeizhQUG95qY6FbAFMh24OTUH+JGgneybabGYEe6HHZr4eDDQ112kKkKNC2bq6LLZZZTmjau7teTz8iA6uVZ8uu6OufhaaZROw+zED4pPTooq1/OCDaBSPFt7GDpGsVMEyV3YAYLRuW3RWaA5dfh0RO7HWswoT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563469966; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=XcldNbSOf6hRBP+bqkXyex2LTJ8rtoMkNiT4gMKSHmA=; b=IHzAPm27EHigF09aNRjLl91GbouStyFNyy8l7DaAgZmQIS9vubu9OcLkt8iy8oLue5+6UuizNVUiTHukQv4Wm51x2DJdihZQ0K26jG53J/bB2SiCgJifzrodO708CkEns0Mr6ix+ZrAOo2SdP7KDZEIVyGGVsj853LQrFDGbQyg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1563469966025815.2106399918812; Thu, 18 Jul 2019 10:12:46 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ho9wV-0004M4-KA; Thu, 18 Jul 2019 17:11:43 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ho9wU-0004Lz-Mx for xen-devel@lists.xenproject.org; Thu, 18 Jul 2019 17:11:42 +0000 Received: from mail-lj1-x242.google.com (unknown [2a00:1450:4864:20::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 1bf7a6dc-a97f-11e9-8980-bc764e045a96; Thu, 18 Jul 2019 17:11:41 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id y17so3525205ljk.10 for ; Thu, 18 Jul 2019 10:11:41 -0700 (PDT) Received: from aanisov-work.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id e13sm5234612ljg.102.2019.07.18.10.11.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Jul 2019 10:11:38 -0700 (PDT) X-Inumbo-ID: 1bf7a6dc-a97f-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ql/Xcu6Ni39j5uAzQSZir2tzV0ZlLopsgeXbWcD3Fu4=; b=KdD0GW3VVGEh6dVPbSBVLapw6F+PCOStkgCh2ltGaczq+Zjbd13awXhSFWCizU0whx b8O+Ycm91+px6mQEdEiHVNYLhWcWHNhyubssXe0XmoiGvvcykej4ugX1ysFGd6DhfFzB 0e6c/EHjGR5CU9Q6IG8SVhHpSVN6a1P/1aeAq5q8qleWFmfCHAtEmbGY8wxmI8XQpxNg QDx7AGZXPu7WqarZ74etQlWIhpurBE5EtFMkex3o06a4ribl6LEoAyOg3sx5zTDOK8th Dpd6tXaUJJ7XnsAmYlQpyg6XH8y+OOZAIHnWHH1pTtD3+J6vyF0GRN8quhFKFjF8OnU3 uR/g== 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; bh=ql/Xcu6Ni39j5uAzQSZir2tzV0ZlLopsgeXbWcD3Fu4=; b=EqMuEmj8wtLaCOIHP+o/H8Ei2OxeNNsBeNr1CtGklHBFCFHYoqPrGKE+ikHCI8ulB0 veY9EJwDOC4M5P+NgXbRpviVMAKDbOeBciPkMwZotKdILMaI+lXaYYwq12wXn2mlNDf2 tFpWeIe3NjpdTZuS3lW/q9tBQrO1Bm3hLWTwWqDAbsnuW0/Ljn++TJUY3lclYRwfHGWz IAhve5qRGFxDUtaISWoU+6D/98dwzHRL3EKvMiOO4xFixcOeVf3/4TXJaKd0fL1/JPuE dsVl0VuRXbLNmPrBku9VixE97PFfDjE3WdJnziLegN7feXI5uVX67AvtaygWsN7IMPLC YWFQ== X-Gm-Message-State: APjAAAUbVkqEASBwu7ei+1nLxauqh5bBsn0pZ1amkSAC7GkzvGQo/ZpG i0IAmKAAa+4jkZE41wOo4puJhuJG X-Google-Smtp-Source: APXvYqzwwaMoq9yzGYiuQo1ZxVmC4faH5VdKWIqtG6FngNF8rW9EoFAybjcOZwrFx99qBF6YFa69zA== X-Received: by 2002:a2e:96d5:: with SMTP id d21mr25369833ljj.170.1563469899675; Thu, 18 Jul 2019 10:11:39 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Thu, 18 Jul 2019 20:11:37 +0300 Message-Id: <1563469897-2773-1-git-send-email-andrii.anisov@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [Xen-devel] [PATCH] vunmap: let vunmap align virtual address by itself X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Andrii Anisov , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Tim Deegan , Julien Grall , Jan Beulich , Ian Jackson , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Andrii Anisov Let vunmap align passed virtual address by PAGE_SIZE. This also makes it consistent with how {,un}map_domain_page() currently works. With the main change, also: - strip all existing vunmap() calls from prior masking - replace opencoded PAGE_MASK macro in vm_index() Signed-off-by: Andrii Anisov Reviewed-by: Andrew Cooper --- xen/arch/x86/mm/shadow/hvm.c | 2 +- xen/common/vmap.c | 4 ++-- xen/drivers/acpi/osl.c | 2 +- xen/include/xen/vmap.h | 4 +--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/mm/shadow/hvm.c b/xen/arch/x86/mm/shadow/hvm.c index c6469c8..8561a11 100644 --- a/xen/arch/x86/mm/shadow/hvm.c +++ b/xen/arch/x86/mm/shadow/hvm.c @@ -597,7 +597,7 @@ static void sh_emulate_unmap_dest(struct vcpu *v, void = *addr, { paging_mark_dirty(v->domain, sh_ctxt->mfn[1]); put_page(mfn_to_page(sh_ctxt->mfn[1])); - vunmap((void *)((unsigned long)addr & PAGE_MASK)); + vunmap(addr); } else unmap_domain_page(addr); diff --git a/xen/common/vmap.c b/xen/common/vmap.c index faebc1d..e7bd6bf 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -141,7 +141,7 @@ static void *vm_alloc(unsigned int nr, unsigned int ali= gn, =20 static unsigned int vm_index(const void *va, enum vmap_region type) { - unsigned long addr =3D (unsigned long)va & ~(PAGE_SIZE - 1); + unsigned long addr =3D (unsigned long)va & PAGE_MASK; unsigned int idx; unsigned long start =3D (unsigned long)vm_base[type]; =20 @@ -225,7 +225,7 @@ void *vmap(const mfn_t *mfn, unsigned int nr) =20 void vunmap(const void *va) { - unsigned long addr =3D (unsigned long)va; + unsigned long addr =3D (unsigned long)va & PAGE_MASK; unsigned int pages =3D vm_size(va, VMAP_DEFAULT); =20 if ( !pages ) diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c index 4c8bb78..1a91453 100644 --- a/xen/drivers/acpi/osl.c +++ b/xen/drivers/acpi/osl.c @@ -115,7 +115,7 @@ void acpi_os_unmap_memory(void __iomem * virt, acpi_siz= e size) } =20 if (system_state >=3D SYS_STATE_boot) - vunmap((void *)((unsigned long)virt & PAGE_MASK)); + vunmap(virt); } =20 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h index 369560e..a556d13 100644 --- a/xen/include/xen/vmap.h +++ b/xen/include/xen/vmap.h @@ -27,9 +27,7 @@ void __iomem *ioremap(paddr_t, size_t); =20 static inline void iounmap(void __iomem *va) { - unsigned long addr =3D (unsigned long)(void __force *)va; - - vunmap((void *)(addr & PAGE_MASK)); + vunmap((void *)va); } =20 void *arch_vmap_virt_end(void); --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel