Skip to contentSkip to conversation

x86/vdso: Remove direct HPET mapping into userspace

PATCH In review Konstantin Khlebnikov 2 participants 4 messages Oct 23, 2019 – Oct 27, 2019 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86/vdso: Remove direct HPET mapping into userspace

commit 1ed95e52d902035e39a715ff3a314a893a96e5b7 upstream.

Commit d96d87834d5b870402a4a5b565706a4869ebc020 in v4.4.190 which is backport of upstream commit 1ed95e52d902035e39a715ff3a314a893a96e5b7 removed only HPET access from vdso but leaved HPET mapped in "vvar". So userspace still could read HPET directly and confuse hardware.

This patch removes mapping HPET page into userspace.

Fixes d96d87834d5b ("x86/vdso: Remove direct HPET access through the vDSO") # v4.4.190
---
 arch/x86/entry/vdso/vma.c |   14 --------------
 1 file changed, 14 deletions(-)
arch/x86/entry/vdso/vma.c +0 -14
index 6b46648588d8..cc0a3c16a95d 100644
@@ -18,7 +18,6 @@
 #include <asm/vdso.h>
 #include <asm/vvar.h>
 #include <asm/page.h>
-#include <asm/hpet.h>
 #include <asm/desc.h>
 #include <asm/cpufeature.h>
 
@@ -159,19 +158,6 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
 	if (ret)
 		goto up_fail;
 
-#ifdef CONFIG_HPET_TIMER
-	if (hpet_address && image->sym_hpet_page) {
-		ret = io_remap_pfn_range(vma,
-			text_start + image->sym_hpet_page,
-			hpet_address >> PAGE_SHIFT,
-			PAGE_SIZE,
-			pgprot_noncached(PAGE_READONLY));
-
-		if (ret)
-			goto up_fail;
-	}
-#endif
-
 	pvti = pvclock_pvti_cpu0_va();
 	if (pvti && image->sym_pvclock_page) {
 		ret = remap_pfn_range(vma,
#1 lore raw

PATCH 2/2 x86/vdso: Remove hpet_page from vDSO

From: Jia Zhang <[email protected]>

Commit 81d30225bc0c246b53270eb90b23cfbb941a186d upstream.

This trivial cleanup finalizes the removal of vDSO HPET support.

---
 arch/x86/entry/vdso/vdso2c.c |    3 ---
 arch/x86/include/asm/vdso.h  |    1 -
 2 files changed, 4 deletions(-)
arch/x86/entry/vdso/vdso2c.c +0 -3
index 491020b2826d..6446ba489eb2 100644
@@ -72,7 +72,6 @@ const char *outfilename;
 enum {
 	sym_vvar_start,
 	sym_vvar_page,
-	sym_hpet_page,
 	sym_pvclock_page,
 	sym_VDSO_FAKE_SECTION_TABLE_START,
 	sym_VDSO_FAKE_SECTION_TABLE_END,
@@ -80,7 +79,6 @@ enum {
 
 const int special_pages[] = {
 	sym_vvar_page,
-	sym_hpet_page,
 	sym_pvclock_page,
 };
 
@@ -92,7 +90,6 @@ struct vdso_sym {
 struct vdso_sym required_syms[] = {
 	[sym_vvar_start] = {"vvar_start", true},
 	[sym_vvar_page] = {"vvar_page", true},
-	[sym_hpet_page] = {"hpet_page", true},
 	[sym_pvclock_page] = {"pvclock_page", true},
 	[sym_VDSO_FAKE_SECTION_TABLE_START] = {
 		"VDSO_FAKE_SECTION_TABLE_START", false
arch/x86/include/asm/vdso.h +0 -1
index deabaf9759b6..c2a1188cd0bf 100644
@@ -21,7 +21,6 @@ struct vdso_image {
 	long sym_vvar_start;  /* Negative offset to the vvar area */
 
 	long sym_vvar_page;
-	long sym_hpet_page;
 	long sym_pvclock_page;
 	long sym_VDSO32_NOTE_MASK;
 	long sym___kernel_sigreturn;
#2 lore raw
In reply to Konstantin Khlebnikov
Quoted 29 lines · Konstantin Khlebnikov

commit 1ed95e52d902035e39a715ff3a314a893a96e5b7 upstream.

Commit d96d87834d5b870402a4a5b565706a4869ebc020 in v4.4.190 which is backport of upstream commit 1ed95e52d902035e39a715ff3a314a893a96e5b7 removed only HPET access from vdso but leaved HPET mapped in "vvar". So userspace still could read HPET directly and confuse hardware.

This patch removes mapping HPET page into userspace.

Fixes d96d87834d5b ("x86/vdso: Remove direct HPET access through the vDSO") # v4.4.190
---
  arch/x86/entry/vdso/vma.c |   14 --------------
  1 file changed, 14 deletions(-)
arch/x86/entry/vdso/vma.c +0 -1
index 6b46648588d8..cc0a3c16a95d 100644
@@ -18,7 +18,6 @@
  #include <asm/vdso.h>
  #include <asm/vvar.h>
  #include <asm/page.h>
-#include <asm/hpet.h>
  #include <asm/desc.h>
  #include <asm/cpufeature.h>
 

arch/x86/entry/vdso/vma.c static int map_vdso(const struct vdso_image *image, bool calculate_addr) · line 163

Quoted 5 lines
arch/x86/entry/vdso/vma.c +0 -2
@@ -159,19 +158,6 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
  	if (ret)
  		goto up_fail;
 
-#ifdef CONFIG_HPET_TIMER
-	if (hpet_address && image->sym_hpet_page) {

Probably this patch is not required.
It seems after removing symbol "hpet_page" from vdso code image->sym_hpet_page always is NULL and this branch never executed.

Quoted 15 lines
arch/x86/entry/vdso/vma.c +0 -11
-		ret = io_remap_pfn_range(vma,
-			text_start + image->sym_hpet_page,
-			hpet_address >> PAGE_SHIFT,
-			PAGE_SIZE,
-			pgprot_noncached(PAGE_READONLY));
-
-		if (ret)
-			goto up_fail;
-	}
-#endif
-
  	pvti = pvclock_pvti_cpu0_va();
  	if (pvti && image->sym_pvclock_page) {
  		ret = remap_pfn_range(vma,
#3 lore raw
Quoted 29 lines · Konstantin Khlebnikov
Quoted 28 lines · Konstantin Khlebnikov

commit 1ed95e52d902035e39a715ff3a314a893a96e5b7 upstream.

Commit d96d87834d5b870402a4a5b565706a4869ebc020 in v4.4.190 which is backport of upstream commit 1ed95e52d902035e39a715ff3a314a893a96e5b7 removed only HPET access from vdso but leaved HPET mapped in "vvar". So userspace still could read HPET directly and confuse hardware.

This patch removes mapping HPET page into userspace.

Fixes d96d87834d5b ("x86/vdso: Remove direct HPET access through the vDSO") # v4.4.190
---
  arch/x86/entry/vdso/vma.c |   14 --------------
  1 file changed, 14 deletions(-)
arch/x86/entry/vdso/vma.c +0 -1
index 6b46648588d8..cc0a3c16a95d 100644
@@ -18,7 +18,6 @@
  #include <asm/vdso.h>
  #include <asm/vvar.h>
  #include <asm/page.h>
-#include <asm/hpet.h>
  #include <asm/desc.h>
  #include <asm/cpufeature.h>
@@ -159,19 +158,6 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
Quoted 8 lines

arch/x86/entry/vdso/vma.c static int map_vdso(const struct vdso_image *image, bool calculate_addr) · line 163

Quoted 4 lines
arch/x86/entry/vdso/vma.c +0 -2
  	if (ret)
  		goto up_fail;
-#ifdef CONFIG_HPET_TIMER
-	if (hpet_address && image->sym_hpet_page) {

Probably this patch is not required.
It seems after removing symbol "hpet_page" from vdso code image->sym_hpet_page always is NULL and this branch never executed.

Ok, so these two patches are not needed? I'll drop them from my todo-queue, thanks.

greg k-h