Hi Youren,
git apply $attached_patch$
I have a meeting to attend to, so I don't have the time to test it right
now; will do it later. I hope it works.
Cheers,
Philipp
On 03/21/2014 09:30 AM, Philipp Eppelt wrote:
> Hi Youren,
>
> I just looked at a fresh RTEMS clone. I thought the patch eliminating
> sensitive instructions from the x86 paravirt target was merged, but it
> looks like it wasn't.
>
> I am working on an up to date patch. The old one, doesn't work anymore.
>
> Cheers,
> Philipp
>
> On 03/21/2014 03:27 AM, Youren Shen wrote:
>> Hi,Gedare:
>>
>> Thank you for your suggestion.
>>
>> In the function bootcart() in the file
>> c/src/lib/libbsp/shared/bootcard.c, there is a
>> function rtems_interrupt_disable which will be compiled to be
>> instruction "cli" in x86 platform. And the cli is also the reason why I
>> failed to startup POK partitions [1].
>>
>> Now I consider there are two ways to solve the problem.One I called
>> functional solution, The other I called instruction solution. That is
>> say , we replace some functions with sensitive instructions or replace
>> every instructions. The first approach seems to be easy to
>> implementation, however maybe not easy to transplant to other platform.
>> I'm more familiar with the second approach, but to implement the whole
>> project will spent more time. And once we finish this project, we can
>> easily implement paravirtualization to other platform. And if design
>> properly, will also easily to transplant RTEMS to other hypervisor.
>>
>> Or we have to mix this two solutions, This needs more discussion and
>> should be thoughtful and deliberate.
>>
>> By the way, I'm going to post a blog about the POK initiation and
>> interrupt system this weekend.
>>
>> [1].
>> http://listengine.tuxfamily.org/lists.tuxfamily.org/pok/2014/03/msg00003.html
>>
>> ---
>> Best Regards.
>> Youren Shen.
>>
>>
>> On Thu, Mar 20, 2014 at 10:04 PM, Gedare Bloom <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> Youren Shen,
>>
>> It looks like the problem you are having is that RTEMS "hello world"
>> executes a sensitive instruction? There should not be any such
>> instruction when you use the --enable-paravirt option, so you need to
>> determine where this instruction gets executed. The best way to do
>> this is to hook gdb up to an executing qemu. You can start qemu with
>> some -S option to prevent the boot sequence from starting to give you
>> some time to load gdb and connect it to qemu's gdbserver socket. once
>> you have done this, you should be able to set some breakpoints in the
>> pok/hello application to step through the program, or you might be
>> able to catch exceptions before they get raised to pok. The other
>> option should be that inside pok there should be some information
>> about the source of the exception that you might investigate.
>>
>> Please keep us informed about your progress on this problem,
>> Thanks,
>> Gedare
>>
>> On Thu, Mar 20, 2014 at 9:16 AM, Youren Shen <[email protected]
>> <mailto:[email protected]>> wrote:
>> > Hi,Gedare
>> >
>> > Maybe it's because my qemu version is low or POK has change the
>> kernel, I
>> > can't run the RTEMS Hello world on my computer anymore.
>> >
>> > The problem has spent me a few days to find. More details see this
>> mails.
>> >
>> > [1].
>> >
>>
>> http://listengine.tuxfamily.org/lists.tuxfamily.org/pok/2014/03/msg00000.html
>> >
>> > -----
>> > Best Regards.
>> > Youren Shen.
>> >
>> >
>> > On Thu, Mar 20, 2014 at 8:03 PM, Philipp Eppelt
>> > <[email protected]
>> <mailto:[email protected]>> wrote:
>> >>
>> >> On 03/16/2014 01:01 PM, Youren Shen wrote:
>> >> > Hi, every one:
>> >> >
>> >> > I have write a blog about how to build the RTEMS on POK.
>> However, the
>> >> > RTEMS can't run on POK now. Here is my blog[1].
>> >> >
>> >> > [1].
>> >> >
>> http://huaiyusched.github.io/rtems/2014/03/15/how-to-run-rtems-on-pok/
>> >> > --
>> >> > Best Regards.
>> >> > Youren Shen.
>> >>
>> >>
>> >> Hi Youren,
>> >>
>> >> great!
>> >> A screenshot of RTEMS HelloWorld sample running on POK would be even
>> >> better :).
>> >>
>> >> Cheers,
>> >> Philipp
>> >
>> >
>> >
>> >
>> > --
>> > Best Regards.
>> > Youren Shen.
>>
>>
>>
>>
>> --
>> Best Regards.
>> Youren Shen.
>
> _______________________________________________
> rtems-devel mailing list
> [email protected]
> http://www.rtems.org/mailman/listinfo/rtems-devel
>
diff --git a/cpukit/score/cpu/i386/Makefile.am b/cpukit/score/cpu/i386/Makefile.am
index 494cd67..2293a3b 100644
--- a/cpukit/score/cpu/i386/Makefile.am
+++ b/cpukit/score/cpu/i386/Makefile.am
@@ -11,6 +11,7 @@ include_rtems_score_HEADERS += rtems/score/interrupts.h
include_rtems_score_HEADERS += rtems/score/registers.h
include_rtems_score_HEADERS += rtems/score/idtr.h
include_rtems_score_HEADERS += rtems/score/cpuatomic.h
+include_rtems_score_HEADERS += rtems/score/virtualizationlayercpu.h
noinst_LIBRARIES = libscorecpu.a
libscorecpu_a_SOURCES = cpu.c cpu_asm.S
diff --git a/cpukit/score/cpu/i386/cpu.c b/cpukit/score/cpu/i386/cpu.c
index ba7501a..b7911fa 100644
--- a/cpukit/score/cpu/i386/cpu.c
+++ b/cpukit/score/cpu/i386/cpu.c
@@ -26,6 +26,8 @@
#include <rtems/bspIo.h>
#include <rtems/score/thread.h>
+#include <rtems/score/virtualizationlayercpu.h>
+
void _CPU_Initialize(void)
{
#if CPU_HARDWARE_FP
@@ -97,6 +99,20 @@ uint32_t _CPU_ISR_Get_level( void )
return level;
}
+
+#if defined(RTEMS_PARAVIRT)
+
+void *_CPU_Thread_Idle_body( uintptr_t ignored )
+{
+ while(1)
+ {
+ _CPU_Virtual_Idle_thread();
+ }
+ return NULL;
+}
+
+#else
+
void *_CPU_Thread_Idle_body( uintptr_t ignored )
{
while(1){
@@ -105,6 +121,8 @@ void *_CPU_Thread_Idle_body( uintptr_t ignored )
return NULL;
}
+#endif /*RTEMS_PARAVIRT*/
+
struct Frame_ {
struct Frame_ *up;
uintptr_t pc;
diff --git a/cpukit/score/cpu/i386/preinstall.am b/cpukit/score/cpu/i386/preinstall.am
index 060176b..4fd8533 100644
--- a/cpukit/score/cpu/i386/preinstall.am
+++ b/cpukit/score/cpu/i386/preinstall.am
@@ -55,3 +55,6 @@ $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_IN
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h
+$(PROJECT_INCLUDE)/rtems/score/virtualizationlayercpu.h: rtems/score/virtualizationlayercpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/virtualizationlayercpu.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/virtualizationlayercpu.h
diff --git a/cpukit/score/cpu/i386/rtems/score/cpu.h b/cpukit/score/cpu/i386/rtems/score/cpu.h
index 296ad8b..2051b30 100644
--- a/cpukit/score/cpu/i386/rtems/score/cpu.h
+++ b/cpukit/score/cpu/i386/rtems/score/cpu.h
@@ -35,6 +35,8 @@ extern "C" {
#include <rtems/score/registers.h> /* formerly part of libcpu */
#endif
+#include <rtems/score/virtualizationlayercpu.h>
+
/* conditional compilation parameters */
#define CPU_INLINE_ENABLE_DISPATCH TRUE
@@ -376,11 +378,22 @@ SCORE_EXTERN Context_Control_fp _CPU_Null_fp_context;
#define _CPU_ISR_Flash( _level ) i386_flash_interrupts( _level )
-#define _CPU_ISR_Set_level( _new_level ) \
- { \
- if ( _new_level ) __asm__ volatile ( "cli" ); \
- else __asm__ volatile ( "sti" ); \
- }
+#if defined(RTEMS_PARAVIRT)
+ #define _CPU_ISR_Set_level( _new_level ) \
+ { \
+ if( _new_level ) _CPU_Virtual_Interrupts_close(); \
+ else _CPU_Virtual_Interrupts_open(); \
+ }
+
+#else
+
+ #define _CPU_ISR_Set_level( _new_level ) \
+ { \
+ if ( _new_level ) __asm__ volatile ( "cli" ); \
+ else __asm__ volatile ( "sti" ); \
+ }
+
+#endif /*RTEMS_PARAVIRT*/
uint32_t _CPU_ISR_Get_level( void );
@@ -496,16 +509,27 @@ uint32_t _CPU_ISR_Get_level( void );
* + disable interrupts and halt the CPU
*/
-#define _CPU_Fatal_halt( _error ) \
+#if defined(RTEMS_PARAVIRT)
+ #define _CPU_Fatal_halt( _error ) \
{ \
- uint32_t _error_lvalue = ( _error ); \
- __asm__ volatile ( "cli ; \
- movl %0,%%eax ; \
- hlt" \
- : "=r" ((_error_lvalue)) : "0" ((_error_lvalue)) \
- ); \
+ _CPU_Virtual_Interrupts_close(); \
+ _CPU_Virtual_Stop_with_error( _error ); \
}
+#else
+
+ #define _CPU_Fatal_halt( _error ) \
+ { \
+ uint32_t _error_lvalue = ( _error ); \
+ __asm__ volatile ( "cli ; \
+ movl %0,%%eax ; \
+ hlt" \
+ : "=r" ((_error_lvalue)) : "0" ((_error_lvalue)) \
+ ); \
+ }
+
+#endif /*RTEMS_PARAVIRT*/
+
#endif /* ASM */
/* end of Fatal Error manager macros */
diff --git a/cpukit/score/cpu/i386/rtems/score/interrupts.h b/cpukit/score/cpu/i386/rtems/score/interrupts.h
index 5ae172a..4233a34 100644
--- a/cpukit/score/cpu/i386/rtems/score/interrupts.h
+++ b/cpukit/score/cpu/i386/rtems/score/interrupts.h
@@ -8,6 +8,8 @@
/*
* COPYRIGHT (c) 1998 [email protected]
+ * COPYRIGHT (c) 2014 Philipp Eppelt.
+ * [email protected]
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -19,6 +21,8 @@
#ifndef _RTEMS_SCORE_INTERRUPTS_H
#define _RTEMS_SCORE_INTERRUPTS_H
+#include <rtems/score/virtualizationlayercpu.h>
+
#ifndef ASM
struct __rtems_raw_irq_connect_data__;
@@ -33,6 +37,35 @@ typedef int (*rtems_raw_irq_is_enabled) (const struct __rtems_raw_irq_connect_d
*
*/
/**@{**/
+#if defined(RTEMS_PARAVIRT)
+
+#define i386_disable_interrupts( _level ) \
+ { \
+ _CPU_Virtual_Interrupts_disable( _level ); \
+ }
+
+#define i386_enable_interrupts( _level ) \
+ { \
+ _CPU_Virtual_Interrupts_enable( _level ); \
+ }
+
+#define i386_flash_interrupts( _level ) \
+ { \
+ _CPU_Virtual_Interrupts_enable(_level); \
+ _CPU_Virtual_Interrupts_disable(_level); \
+ }
+
+#define i386_get_interrupt_level( _level ) \
+ { \
+ _CPU_Virtual_Interrupts_get_level( _level ); \
+ }
+
+#define _CPU_ISR_Disable( _level ) i386_disable_interrupts( _level )
+#define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level )
+
+
+#else /*RTEMS_PARAVIRT*/
+
#define i386_disable_interrupts( _level ) \
{ \
@@ -75,7 +108,8 @@ typedef int (*rtems_raw_irq_is_enabled) (const struct __rtems_raw_irq_connect_d
#define _CPU_ISR_Disable( _level ) i386_disable_interrupts( _level )
#define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level )
+#endif /*RTEMS_PARAVIRT*/
/** @} */
-#endif
-#endif
+#endif /* ASM */
+#endif /* _RTEMS_SCORE_INTERRUPTS_H */
diff --git a/cpukit/score/cpu/i386/rtems/score/virtualizationlayercpu.h b/cpukit/score/cpu/i386/rtems/score/virtualizationlayercpu.h
new file mode 100644
index 0000000..9834f82
--- /dev/null
+++ b/cpukit/score/cpu/i386/rtems/score/virtualizationlayercpu.h
@@ -0,0 +1,91 @@
+/*
+ *
+ * COPYRIGHT (c) 2013 Philipp Eppelt.
+ * [email protected]
+ *
+ * Purpose: CPU part of the virtualization layer.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if defined(RTEMS_PARAVIRT)
+
+#ifndef RTEMS_VIRT_LAYER_CPU_H
+#define RTEMS_VIRT_LAYER_CPU_H
+
+#ifndef ASM
+
+/* Interrupts */
+
+/**
+ * \brief Requests an interrupt vector.
+ */
+int
+_CPU_Virtual_Irq_request( int vector );
+
+/**
+ * \brief Releases an interrupt vector.
+ */
+void
+_CPU_Virtual_Irq_detach( int vector );
+
+/**
+ * \brief Enables interrupt delivery or sets it to the specified level.
+ *
+ * Use this function in collaboration with _CPU_Virtual_Interrupts_disable and
+ * use its returned _level as argument to this function to assure proper
+ * behaviour.
+ */
+void
+_CPU_Virtual_Interrupts_enable( int _level );
+
+/**
+ * \brief Disables interrupt delivery and returns the previous level.
+ *
+ */
+void
+_CPU_Virtual_Interrupts_disable( int _level );
+
+/**
+ * \brief Enables and directly disables interrupt delivery.
+ */
+void
+_CPU_Virtual_Interrupts_flash( int _level );
+
+/**
+ * \brief Requests the current interrupt level.
+ */
+int
+_CPU_Virtual_Interrupts_get_level( int _level );
+
+
+void
+_CPU_Virtual_Interrupts_open(void);
+void
+_CPU_Virtual_Interrupts_close( void );
+
+/* Idle Thread */
+
+/**
+ * \brief Lowest priority thread, doing nothing, never returns;
+ */
+
+void
+_CPU_Virtual_Idle_thread( void );
+
+
+/* Error handling */
+
+/**
+ * \brief Handlers execution errors.
+ */
+void
+_CPU_Virtual_Stop_with_error( int _error );
+
+#endif /* ASM */
+
+#endif /* RTEMS_VIRT_LAYER_CPU_H */
+
+#endif /*RTEMS_PARAVIRT*/
_______________________________________________
rtems-devel mailing list
[email protected]
http://www.rtems.org/mailman/listinfo/rtems-devel