2 * (C) Copyright 2007-2010 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
11 struct address_space
{
12 struct dat_rte
*region_table
;
13 struct dat_ste
*segment_table
;
16 /* region/segment-table destination */
18 u64 origin
:52, /* region/segment table origin */
20 g
:1, /* subspace-group control */
21 p
:1, /* private-space control */
22 s
:1, /* storage-alteration-event ctl */
23 x
:1, /* space-switch-event control */
24 r
:1, /* real-space control */
26 dt
:2, /* designation-type control */
27 tl
:2; /* table length */
28 } __attribute__((packed
));
30 #define DAT_TD_DT_RFT 3 /* region-first */
31 #define DAT_TD_DT_RST 2 /* region-second */
32 #define DAT_TD_DT_RTT 1 /* region-third */
33 #define DAT_TD_DT_ST 0 /* segment */
35 /* region-table entries (first, second, and third) */
37 u64 origin
:52, /* next-level-table origin */
39 tf
:2, /* table offset (next lower tbl) */
40 i
:1, /* region invalid */
42 tt
:2, /* table-type bits (current tbl) */
43 tl
:2; /* table length (next lower tbl) */
44 } __attribute__((packed
));
47 * Constants for struct rte
49 #define DAT_RTE_TT_RFT 3 /* region-first */
50 #define DAT_RTE_TT_RST 2 /* region-second */
51 #define DAT_RTE_TT_RTT 1 /* region-third */
53 #define ADDR_TO_RTE_ORIGIN(a) ((a) >> 12)
54 #define RTE_ORIGIN_TO_ADDR(o) ((void*)(((u64)(o)) << 12))
56 /* segment-table entries */
58 u64 origin
:53, /* page-table origin */
60 p
:1, /* page-protection bit */
62 i
:1, /* segment-invalid bit */
63 c
:1, /* common-segment bit */
64 tt
:2, /* table-type bits */
66 } __attribute__((packed
));
68 #define DAT_STE_TT_ST 0 /* segment-table */
70 #define ADDR_TO_STE_ORIGIN(a) ((a) >> 11)
71 #define STE_ORIGIN_TO_ADDR(o) ((void*)(((u64)(o)) << 11))
73 /* page-table entries */
75 u64 pfra
:52, /* page-frame real address */
77 i
:1, /* page-invalid bit */
78 p
:1, /* page-protection bit */
81 } __attribute__((packed
));
83 #define DAT_RX(addr) (((u64)(addr)) >> 31)
84 #define DAT_SX(addr) ((((u64)(addr)) >> 20) & 0x7ff)
85 #define DAT_PX(addr) ((((u64)(addr)) >> 12) & 0xff)
86 #define DAT_BX(addr) (((u64)(addr))& 0xfff)
88 extern int dat_insert_page(struct address_space
*as
, u64 phy
, u64 virt
);
89 extern void setup_dat(void);
90 extern void load_as(struct address_space
*as
);
92 extern int virt2phy(struct address_space
*as
, u64 virt
, u64
*phy
);
94 static inline void store_pasce(u64
*pasce
)
104 static inline void load_pasce(u64 pasce
)
117 /* get host real address from guest real, using the currently loaded ASCE */
118 static inline int virt2phy_current(u64 virt
, u64
*phy
)
124 " lrag %0,0(%%r0,%2)\n"
143 #define memcpy_to_guest(gaddr, ptr, len) __memcpy_tofrom_guest((gaddr), (ptr), (len), 0)
144 #define memcpy_from_guest(gaddr, ptr, len) __memcpy_tofrom_guest((gaddr), (ptr), (len), 1)
146 extern int __memcpy_tofrom_guest(u64 guest_addr
, void *data
, u64
*len
, int from
);