All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Gordeev <agordeev@redhat.com>
To: kvm@vger.kernel.org
Cc: "Alexander Gordeev" <agordeev@redhat.com>,
	"Andrew Jones" <drjones@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Subject: [kvm-unit-tests PATCH v7 03/11] x86: Introduce lib/x86/asm/page.h
Date: Thu,  5 May 2016 16:26:36 +0200	[thread overview]
Message-ID: <f903448bf2e06ffd81c6ce087642637918958ff1.1462457467.git.agordeev@redhat.com> (raw)
In-Reply-To: <cover.1462457467.git.agordeev@redhat.com>

Make x86 consistent with other architectures and put
memory page specific defines to lib/x86/asm/page.h

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/x86/asm/page.h | 33 +++++++++++++++++++++++++++++++++
 lib/x86/vm.c       | 17 -----------------
 lib/x86/vm.h       | 14 +-------------
 3 files changed, 34 insertions(+), 30 deletions(-)
 create mode 100644 lib/x86/asm/page.h

diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h
new file mode 100644
index 0000000..d4580b4
--- /dev/null
+++ b/lib/x86/asm/page.h
@@ -0,0 +1,33 @@
+#ifndef _ASM_X86_PAGE_H_
+#define _ASM_X86_PAGE_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Alexander Gordeev <agordeev@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+
+#define PAGE_SIZE	4096ul
+#ifdef __x86_64__
+#define LARGE_PAGE_SIZE	(512 * PAGE_SIZE)
+#else
+#define LARGE_PAGE_SIZE	(1024 * PAGE_SIZE)
+#endif
+
+#define PTE_PRESENT	(1ull << 0)
+#define PTE_WRITE	(1ull << 1)
+#define PTE_USER	(1ull << 2)
+#define PTE_PSE		(1ull << 7)
+#define PTE_ADDR	(0xffffffffff000ull)
+
+#ifdef __x86_64__
+#define	PAGE_LEVEL	4
+#define	PGDIR_WIDTH	9
+#define	PGDIR_MASK	511
+#else
+#define	PAGE_LEVEL	2
+#define	PGDIR_WIDTH	10
+#define	PGDIR_MASK	1023
+#endif
+
+#endif
diff --git a/lib/x86/vm.c b/lib/x86/vm.c
index 7ce7bbc..9c94ca5 100644
--- a/lib/x86/vm.c
+++ b/lib/x86/vm.c
@@ -2,13 +2,6 @@
 #include "vm.h"
 #include "libcflat.h"
 
-#define PAGE_SIZE 4096ul
-#ifdef __x86_64__
-#define LARGE_PAGE_SIZE (512 * PAGE_SIZE)
-#else
-#define LARGE_PAGE_SIZE (1024 * PAGE_SIZE)
-#endif
-
 static void *free = 0;
 static void *vfree_top = 0;
 
@@ -44,16 +37,6 @@ void free_page(void *page)
 extern char edata;
 static unsigned long end_of_memory;
 
-#ifdef __x86_64__
-#define	PAGE_LEVEL	4
-#define	PGDIR_WIDTH	9
-#define	PGDIR_MASK	511
-#else
-#define	PAGE_LEVEL	2
-#define	PGDIR_WIDTH	10
-#define	PGDIR_MASK	1023
-#endif
-
 unsigned long *install_pte(unsigned long *cr3,
 			   int pte_level,
 			   void *virt,
diff --git a/lib/x86/vm.h b/lib/x86/vm.h
index 28794d7..72f84e6 100644
--- a/lib/x86/vm.h
+++ b/lib/x86/vm.h
@@ -2,19 +2,7 @@
 #define VM_H
 
 #include "processor.h"
-
-#define PAGE_SIZE 4096ul
-#ifdef __x86_64__
-#define LARGE_PAGE_SIZE (512 * PAGE_SIZE)
-#else
-#define LARGE_PAGE_SIZE (1024 * PAGE_SIZE)
-#endif
-
-#define PTE_PRESENT (1ull << 0)
-#define PTE_PSE     (1ull << 7)
-#define PTE_WRITE   (1ull << 1)
-#define PTE_USER    (1ull << 2)
-#define PTE_ADDR    (0xffffffffff000ull)
+#include "asm/page.h"
 
 void setup_vm();
 
-- 
1.8.3.1


  parent reply	other threads:[~2016-05-05 14:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-05 14:26 [kvm-unit-tests PATCH v7 00/11] Cleanup low-level arch code Alexander Gordeev
2016-05-05 14:26 ` [kvm-unit-tests PATCH v7 01/11] Remove unused and unnecessary PHYS32 macro Alexander Gordeev
2016-05-05 14:26 ` [kvm-unit-tests PATCH v7 02/11] Move phys_addr_t type definition to lib/libcflat.h Alexander Gordeev
2016-05-05 14:26 ` Alexander Gordeev [this message]
2016-05-05 14:26 ` [kvm-unit-tests PATCH v7 04/11] x86: Introduce lib/x86/asm/io.h Alexander Gordeev
2016-05-05 14:26 ` [kvm-unit-tests PATCH v7 05/11] x86: Introduce lib/x86/asm/barrier.h Alexander Gordeev
2016-05-05 14:26 ` [kvm-unit-tests PATCH v7 06/11] io: Separate overrides of virt_to_phys() and phys_to_virt() Alexander Gordeev
2016-05-05 14:26 ` [kvm-unit-tests PATCH v7 07/11] io: Disallow memory re-ordering for generic memory barriers Alexander Gordeev
2016-05-05 14:26 ` [kvm-unit-tests PATCH v7 08/11] x86: Cleanup PAGE_* constants Alexander Gordeev
2016-05-05 14:26 ` [kvm-unit-tests PATCH v7 09/11] x86: Cleanup PT_*_MASK flags Alexander Gordeev
2016-05-06  9:04   ` Andrew Jones
2016-05-06 11:22     ` [kvm-unit-tests PATCH v8 " Alexander Gordeev
2016-05-05 14:26 ` [kvm-unit-tests PATCH v7 10/11] io: Make ioremap() prototype conform to Linux one Alexander Gordeev
2016-05-05 14:26 ` [kvm-unit-tests PATCH v7 11/11] x86: io: Factor out ioremap() Alexander Gordeev
2016-05-06  9:06   ` Andrew Jones
2016-05-06  9:08 ` [kvm-unit-tests PATCH v7 00/11] Cleanup low-level arch code Andrew Jones
2016-05-06 11:29   ` Alexander Gordeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f903448bf2e06ffd81c6ce087642637918958ff1.1462457467.git.agordeev@redhat.com \
    --to=agordeev@redhat.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.