5 new revisions:
Revision: f217b93fd62f
Branch: default
Author: Jack Lange <
jack....@gmail.com>
Date: Mon Oct 21 22:42:09 2013 UTC
Log: This updates the pmem_add implementation to add a check to make
sure t...
http://code.google.com/p/kitten/source/detail?r=f217b93fd62f
Revision: 1f9d64809487
Branch: default
Author: Jack Lange <
jack....@gmail.com>
Date: Mon Oct 21 22:54:05 2013 UTC
Log: This adds a new function to send IPIs to an explicit APIC even if
it i...
http://code.google.com/p/kitten/source/detail?r=1f9d64809487
Revision: 8b5b6d8cd8e8
Branch: default
Author: Jack Lange <
jack....@gmail.com>
Date: Mon Oct 21 22:56:05 2013 UTC
Log: This fixes a header file dependency issue in
include/arch/proto.h. One...
http://code.google.com/p/kitten/source/detail?r=8b5b6d8cd8e8
Revision: 7358a7f83db6
Branch: default
Author: Jack Lange <
jack....@gmail.com>
Date: Mon Oct 21 23:04:24 2013 UTC
Log: This changes the Kitten IPI vectors to not overlap with Linux....
http://code.google.com/p/kitten/source/detail?r=7358a7f83db6
Revision: 07d8644c28fa
Branch: default
Author: Jack Lange <
jack....@gmail.com>
Date: Mon Oct 21 23:22:00 2013 UTC
Log: This patch changes the logical ID of each local APIC to 0. Since
Kitte...
http://code.google.com/p/kitten/source/detail?r=07d8644c28fa
==============================================================================
Revision: f217b93fd62f
Branch: default
Author: Jack Lange <
jack....@gmail.com>
Date: Mon Oct 21 22:42:09 2013 UTC
Log: This updates the pmem_add implementation to add a check to make
sure that the
physical memory is mapped into the kernel's virtual address space. This
allows
us to insert memory into Kitten via a special daemon running in Kitten's
userspace that is communicating with a management service on the Linux side.
The thinking is that we bootstrap Kitten with a single core and a small
block
of memory, and then dynamically add/remove resources as needed.
http://code.google.com/p/kitten/source/detail?r=f217b93fd62f
Modified:
/arch/x86_64/mm/aspace.c
/include/lwk/aspace.h
/kernel/mm/pmem.c
=======================================
--- /arch/x86_64/mm/aspace.c Thu Aug 26 16:16:54 2010 UTC
+++ /arch/x86_64/mm/aspace.c Mon Oct 21 22:42:09 2013 UTC
@@ -330,6 +330,13 @@
_pte.global = 1;
if ((flags & VM_EXEC) == 0)
_pte.no_exec = 1;
+ if (flags & VM_KERNEL) {
+ _pte.global = 1;
+ _pte.write = 1;
+ _pte.no_exec = 1;
+ _pte.accessed = 1;
+ _pte.dirty = 1;
+ }
_pte.base_paddr = paddr >> 12;
if ((pagesz == VM_PAGE_2MB) || (pagesz == VM_PAGE_1GB))
@@ -502,3 +509,41 @@
*paddr = result;
return 0;
}
+
+
+/**
+ * This maps a region of physical memory into the kernel virtual address
space.
+ * It assumes start and end are aligned to a 2 MB boundary and that the
+ * kernel is using 2 MB pages to map physical memory into the kernel
virtual
+ * address space.
+ */
+int
+arch_aspace_map_pmem_into_kernel(paddr_t start, paddr_t end)
+{
+ paddr_t paddr;
+ int status;
+
+ for (paddr = start; paddr < end; paddr += VM_PAGE_2MB) {
+ /* If the page isn't already mapped, we need to map it */
+ if (arch_aspace_virt_to_phys(&bootstrap_aspace, (vaddr_t)__va(paddr),
NULL) == -ENOENT) {
+ printk(KERN_INFO "Missing kernel memory found, paddr=0x%016lx.\n",
paddr);
+
+ status =
+ arch_aspace_map_page(
+ &bootstrap_aspace,
+ (vaddr_t)__va(paddr),
+ paddr,
+ VM_KERNEL,
+ VM_PAGE_2MB
+ );
+
+ if (status) {
+ printk(KERN_ERR "Could not map kernel memory for paddr=0x%016lx.\n",
paddr);
+ printk(KERN_ERR "Kernel address space is now inconsistent.\n");
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
=======================================
--- /include/lwk/aspace.h Tue Jun 22 22:19:44 2010 UTC
+++ /include/lwk/aspace.h Mon Oct 21 22:42:09 2013 UTC
@@ -391,6 +391,12 @@
paddr_t * paddr
);
+extern int
+arch_aspace_map_pmem_into_kernel(
+ paddr_t start,
+ paddr_t end
+);
+
// End architecture specific address space functions
=======================================
--- /kernel/mm/pmem.c Wed Sep 4 11:42:11 2013 UTC
+++ /kernel/mm/pmem.c Mon Oct 21 22:42:09 2013 UTC
@@ -6,6 +6,7 @@
#include <lwk/list.h>
#include <lwk/log2.h>
#include <lwk/pmem.h>
+#include <lwk/aspace.h>
#include <arch/uaccess.h>
static LIST_HEAD(pmem_list);
@@ -204,6 +205,16 @@
entry->rgn = *rgn;
+ /* Map the pmem region into the kernel, if it isn't already.
+ * Normally all memory will be mapped during bootstrap, so
+ * this will effectively be a NOP. The U. Pittsburgh mode
+ * where Kitten boots on a subset of a node's resources
+ * dynamically adds physical memory by calling pmem_add(),
+ * in which case this arch_aspace_map_pmem_into_kernel() call
+ * will dynamically map the pmem into the kernel's virtual
+ * address space. */
+ arch_aspace_map_pmem_into_kernel(rgn->start, rgn->end);
+
insert_pmem_list_entry(entry);
merge_pmem_list();
==============================================================================
Revision: 1f9d64809487
Branch: default
Author: Jack Lange <
jack....@gmail.com>
Date: Mon Oct 21 22:54:05 2013 UTC
Log: This adds a new function to send IPIs to an explicit APIC even if
it is not
associated with a CPU Kitten is currently using. This allows us to send
IPI's
from Kitten to Linux.
http://code.google.com/p/kitten/source/detail?r=1f9d64809487
Modified:
/arch/x86_64/kernel/lapic.c
/include/arch-x86_64/apic.h
=======================================
--- /arch/x86_64/kernel/lapic.c Tue Jul 13 15:43:19 2010 UTC
+++ /arch/x86_64/kernel/lapic.c Mon Oct 21 22:54:05 2013 UTC
@@ -330,16 +330,37 @@
unsigned int vector /* Interrupt vector to send */
)
{
- uint32_t status;
unsigned int apic_id;
+ /* Find target APIC */
+ apic_id = cpu_info[cpu].arch.apic_id;
+
+ lapic_send_ipi_to_apic(apic_id, vector);
+}
+
+/**
+ * Sends an inter-processor interrupt (IPI) to a specific APIC ID.
+ * This works even if the APIC ID is not associated with a CPU that Kitten
+ * is currently running on, making it useful for hotplug-like functionality
+ * and for sending IPIs from Kitten cores to Linux cores (in a FusedOS-like
+ * approach).
+ * Note that the IPI has not necessarily been delivered when this function
+ * returns.
+ */
+void
+lapic_send_ipi_to_apic(
+ unsigned int apic_id, /* APIC ID */
+ unsigned int vector /* Interrupt vector to send */
+)
+{
+ uint32_t status;
+
/* Wait for idle */
status = lapic_wait4_icr_idle();
if (status)
panic("lapic_wait4_icr_idle() timed out. (%x)", status);
- /* Set target CPU */
- apic_id = cpu_info[cpu].arch.apic_id;
+ /* Set target APIC */
apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(apic_id));
/* Send the IPI */
=======================================
--- /include/arch-x86_64/apic.h Mon Aug 2 17:47:48 2010 UTC
+++ /include/arch-x86_64/apic.h Mon Oct 21 22:54:05 2013 UTC
@@ -111,5 +111,6 @@
extern void lapic_send_init_ipi(unsigned int cpu);
extern void lapic_send_startup_ipi(unsigned int cpu, unsigned long
start_rip);
extern void lapic_send_ipi(unsigned int cpu, unsigned int vector);
+extern void lapic_send_ipi_to_apic(unsigned int apic_id, unsigned int
vector);
#endif /* __ASM_APIC_H */
==============================================================================
Revision: 8b5b6d8cd8e8
Branch: default
Author: Jack Lange <
jack....@gmail.com>
Date: Mon Oct 21 22:56:05 2013 UTC
Log: This fixes a header file dependency issue in
include/arch/proto.h. One of the
functions is declared as __init, which was not being included.
http://code.google.com/p/kitten/source/detail?r=8b5b6d8cd8e8
Modified:
/include/arch-x86_64/proto.h
=======================================
--- /include/arch-x86_64/proto.h Tue Jun 22 22:19:44 2010 UTC
+++ /include/arch-x86_64/proto.h Mon Oct 21 22:56:05 2013 UTC
@@ -7,6 +7,7 @@
#define _X86_64_PROTO_H
#include <arch/ptrace.h>
+#include <lwk/init.h>
/* misc architecture specific prototypes */
==============================================================================
Revision: 7358a7f83db6
Branch: default
Author: Jack Lange <
jack....@gmail.com>
Date: Mon Oct 21 23:04:24 2013 UTC
Log: This changes the Kitten IPI vectors to not overlap with Linux.
This avoids confusion if either Linux or Kitten wants to send out
an IPI broadcast.
http://code.google.com/p/kitten/source/detail?r=7358a7f83db6
Modified:
/arch/x86_64/kernel/interrupts.c
/arch/x86_64/kernel/xcall.c
/include/arch-x86_64/idt_vectors.h
=======================================
--- /arch/x86_64/kernel/interrupts.c Mon Jun 10 22:05:51 2013 UTC
+++ /arch/x86_64/kernel/interrupts.c Mon Oct 21 23:04:24 2013 UTC
@@ -368,8 +368,8 @@
/*
* Register handlers for inter-CPU interrupts (cross calls).
*/
- set_idtvec_handler( XCALL_FUNCTION_VECTOR,
&arch_xcall_function_interrupt );
- set_idtvec_handler( XCALL_RESCHEDULE_VECTOR,
&arch_xcall_reschedule_interrupt );
+ set_idtvec_handler( LWK_XCALL_FUNCTION_VECTOR,
&arch_xcall_function_interrupt );
+ set_idtvec_handler( LWK_XCALL_RESCHEDULE_VECTOR,
&arch_xcall_reschedule_interrupt );
}
=======================================
--- /arch/x86_64/kernel/xcall.c Tue Jun 22 22:19:44 2010 UTC
+++ /arch/x86_64/kernel/xcall.c Mon Oct 21 23:04:24 2013 UTC
@@ -74,7 +74,7 @@
/* Send inter-processor interrupts to the target CPUs */
for_each_cpu_mask(cpu, cpu_mask)
- lapic_send_ipi(cpu, XCALL_FUNCTION_VECTOR);
+ lapic_send_ipi(cpu, LWK_XCALL_FUNCTION_VECTOR);
/* Wait for initiation responses */
while (atomic_read(&data.started) != num_cpus)
@@ -124,7 +124,7 @@
if (cpu == this_cpu)
set_bit(TF_NEED_RESCHED_BIT, ¤t->arch.flags);
else
- lapic_send_ipi(cpu, XCALL_RESCHEDULE_VECTOR);
+ lapic_send_ipi(cpu, LWK_XCALL_RESCHEDULE_VECTOR);
}
/**
=======================================
--- /include/arch-x86_64/idt_vectors.h Wed Oct 8 17:28:55 2008 UTC
+++ /include/arch-x86_64/idt_vectors.h Mon Oct 21 23:04:24 2013 UTC
@@ -77,12 +77,12 @@
#define INVALIDATE_TLB_5_VECTOR 245
#define INVALIDATE_TLB_6_VECTOR 246
#define INVALIDATE_TLB_7_VECTOR 247
-/* 248 is available */
+#define LWK_XCALL_FUNCTION_VECTOR 248
#define APIC_PERF_COUNTER_VECTOR 249
#define APIC_THERMAL_VECTOR 250
-/* 251 is available */
-#define XCALL_FUNCTION_VECTOR 252
-#define XCALL_RESCHEDULE_VECTOR 253
+#define LWK_XCALL_RESCHEDULE_VECTOR 251
+#define LINUX_XCALL_FUNCTION_VECTOR 252
+#define LINUX_XCALL_RESCHEDULE_VECTOR 253
#define APIC_ERROR_VECTOR 254
#define APIC_SPURIOUS_VECTOR 255
==============================================================================
Revision: 07d8644c28fa
Branch: default
Author: Jack Lange <
jack....@gmail.com>
Date: Mon Oct 21 23:22:00 2013 UTC
Log: This patch changes the logical ID of each local APIC to 0. Since
Kitten uses
physical APIC IDs this should have no impact on current behavior. This is
necessary for us because Linux sends out priority based IPIs matching a
logical
ID mask. As a result Kitten's APIC would occasionally accept device IRQs and
also receive Linux IPIs. This change prevents that from occuring.
http://code.google.com/p/kitten/source/detail?r=07d8644c28fa
Modified:
/arch/x86_64/kernel/lapic.c
=======================================
--- /arch/x86_64/kernel/lapic.c Mon Oct 21 22:54:05 2013 UTC
+++ /arch/x86_64/kernel/lapic.c Mon Oct 21 23:22:00 2013 UTC
@@ -73,11 +73,10 @@
/*
* Initialize the Logical Destination Register.
- * The LWK never uses logical destination mode, so just set it to the
- * APIC's physical ID to avoid possible confusion.
+ * The LWK never uses logical destination mode, so just set it to zero.
*/
val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
- val |= SET_APIC_LOGICAL_ID( GET_APIC_ID(apic_read(APIC_ID)) );
+ val |= SET_APIC_LOGICAL_ID(0);
apic_write(APIC_LDR, val);
/*