ia64/xen-unstable

changeset 11821:fffb36174ddb

[IA64] merge pal emulator

Merge VTi pal emulator with Xen pal emulator.
Xen/ia64 now has only one pal and one sal emulator.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Wed Oct 18 22:06:38 2006 -0600 (2006-10-18)
parents c13c3bd7f3b5
children aed7ef54fbfe
files xen/arch/ia64/vmx/pal_emul.c xen/arch/ia64/xen/fw_emul.c
line diff
     1.1 --- a/xen/arch/ia64/vmx/pal_emul.c	Wed Oct 18 22:06:23 2006 -0600
     1.2 +++ b/xen/arch/ia64/vmx/pal_emul.c	Wed Oct 18 22:06:38 2006 -0600
     1.3 @@ -17,509 +17,46 @@
     1.4   * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
     1.5   * Place - Suite 330, Boston, MA 02111-1307 USA.
     1.6   */
     1.7 -
     1.8 -#include <asm/vmx_vcpu.h>
     1.9 +  
    1.10 +#include <xen/lib.h>
    1.11 +#include <asm/vcpu.h>
    1.12 +#include <asm/dom_fw.h>
    1.13  #include <asm/pal.h>
    1.14  #include <asm/sal.h>
    1.15 -#include <asm/dom_fw.h>
    1.16 -#include <asm/tlb.h>
    1.17 -#include <asm/vmx_mm_def.h>
    1.18 -#include <xen/hypercall.h>
    1.19 -#include <public/sched.h>
    1.20  
    1.21 -/*
    1.22 - * Handy macros to make sure that the PAL return values start out
    1.23 - * as something meaningful.
    1.24 - */
    1.25 -#define INIT_PAL_STATUS_UNIMPLEMENTED(x)		\
    1.26 -	{						\
    1.27 -		x.status = PAL_STATUS_UNIMPLEMENTED;	\
    1.28 -		x.v0 = 0;				\
    1.29 -		x.v1 = 0;				\
    1.30 -		x.v2 = 0;				\
    1.31 -	}
    1.32 -
    1.33 -#define INIT_PAL_STATUS_SUCCESS(x)			\
    1.34 -	{						\
    1.35 -	       	x.status = PAL_STATUS_SUCCESS;		\
    1.36 -		x.v0 = 0;				\
    1.37 -		x.v1 = 0;				\
    1.38 -		x.v2 = 0;				\
    1.39 -	}
    1.40 -
    1.41 -static void
    1.42 -get_pal_parameters(VCPU *vcpu, u64 *gr29, u64 *gr30, u64 *gr31) {
    1.43 -
    1.44 -	vcpu_get_gr_nat(vcpu,29,gr29);
    1.45 -	vcpu_get_gr_nat(vcpu,30,gr30); 
    1.46 -	vcpu_get_gr_nat(vcpu,31,gr31);
    1.47 -}
    1.48 -
    1.49 -static void
    1.50 -set_pal_result(VCPU *vcpu,struct ia64_pal_retval result) {
    1.51 -
    1.52 -	vcpu_set_gr(vcpu,8, result.status,0);
    1.53 -	vcpu_set_gr(vcpu,9, result.v0,0);
    1.54 -	vcpu_set_gr(vcpu,10, result.v1,0);
    1.55 -	vcpu_set_gr(vcpu,11, result.v2,0);
    1.56 -}
    1.57 -
    1.58 -static void
    1.59 -set_sal_result(VCPU *vcpu,struct sal_ret_values result) {
    1.60 -
    1.61 -	vcpu_set_gr(vcpu,8, result.r8,0);
    1.62 -	vcpu_set_gr(vcpu,9, result.r9,0);
    1.63 -	vcpu_set_gr(vcpu,10, result.r10,0);
    1.64 -	vcpu_set_gr(vcpu,11, result.r11,0);
    1.65 -}
    1.66 -
    1.67 -static struct ia64_pal_retval
    1.68 -pal_cache_flush(VCPU *vcpu) {
    1.69 -	u64 gr28,gr29, gr30, gr31;
    1.70 -	struct ia64_pal_retval result;
    1.71 -
    1.72 -	get_pal_parameters(vcpu, &gr29, &gr30, &gr31);
    1.73 -	vcpu_get_gr_nat(vcpu, 28, &gr28);
    1.74 -
    1.75 -	/* Always call Host Pal in int=1 */
    1.76 -	gr30 = gr30 & ~0x2UL;
    1.77 -
    1.78 -	/*
    1.79 -	 * Call Host PAL cache flush
    1.80 -	 * Clear psr.ic when call PAL_CACHE_FLUSH
    1.81 -	 */
    1.82 -	result = ia64_pal_call_static(gr28 ,gr29, gr30, gr31, 1);
    1.83 -
    1.84 -	/* If host PAL call is interrupted, then loop to complete it */
    1.85 -//	while (result.status == 1)
    1.86 -//		ia64_pal_call_static(gr28 ,gr29, gr30, result.v1, 1LL);
    1.87 -//
    1.88 -	if (result.status != 0)
    1.89 -		panic_domain(vcpu_regs(vcpu), "PAL_CACHE_FLUSH ERROR, "
    1.90 -		             "status %ld", result.status);
    1.91 -
    1.92 -	return result;
    1.93 -}
    1.94 -
    1.95 -static struct ia64_pal_retval
    1.96 -pal_vm_tr_read(VCPU *vcpu) {
    1.97 -	struct ia64_pal_retval result;
    1.98 -
    1.99 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.100 -
   1.101 -	return result;
   1.102 -}
   1.103 -
   1.104 -static struct ia64_pal_retval
   1.105 -pal_prefetch_visibility(VCPU *vcpu) {
   1.106 -	/* Due to current MM virtualization algorithm,
   1.107 -	 * We do not allow guest to change mapping attribute.
   1.108 -	 * Thus we will not support PAL_PREFETCH_VISIBILITY
   1.109 -	 */
   1.110 -	struct ia64_pal_retval result;
   1.111 -
   1.112 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.113 -
   1.114 -	return result;
   1.115 -}
   1.116 -
   1.117 -static struct ia64_pal_retval
   1.118 -pal_platform_addr(VCPU *vcpu) {
   1.119 -	struct ia64_pal_retval result;
   1.120 -
   1.121 -	INIT_PAL_STATUS_SUCCESS(result);
   1.122 -
   1.123 -	return result;
   1.124 -}
   1.125 -
   1.126 -static struct ia64_pal_retval
   1.127 -pal_halt(VCPU *vcpu) {
   1.128 -	//bugbug: to be implement. 
   1.129 -	struct ia64_pal_retval result;
   1.130 -
   1.131 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.132 -
   1.133 -	return result;
   1.134 -}
   1.135 -
   1.136 -static struct ia64_pal_retval
   1.137 -pal_halt_light(VCPU *vcpu) {
   1.138 -	struct ia64_pal_retval result;
   1.139 -	
   1.140 -	if (!is_unmasked_irq(vcpu))
   1.141 -		do_sched_op_compat(SCHEDOP_block, 0);
   1.142 -	    
   1.143 -	INIT_PAL_STATUS_SUCCESS(result);
   1.144 -
   1.145 -	return result;
   1.146 -}
   1.147 -
   1.148 -static struct ia64_pal_retval
   1.149 -pal_cache_read(VCPU *vcpu) {
   1.150 -	struct ia64_pal_retval result;
   1.151 -
   1.152 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.153 -
   1.154 -	return result;
   1.155 -}
   1.156 -
   1.157 -static struct ia64_pal_retval
   1.158 -pal_cache_write(VCPU *vcpu) {
   1.159 -	struct ia64_pal_retval result;
   1.160 -
   1.161 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.162 -
   1.163 -	return result;
   1.164 -}
   1.165 -
   1.166 -static struct ia64_pal_retval
   1.167 -pal_bus_get_features(VCPU *vcpu) {
   1.168 -	struct ia64_pal_retval result;
   1.169 -
   1.170 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.171 -
   1.172 -	return result;
   1.173 -}
   1.174 -
   1.175 -static struct ia64_pal_retval
   1.176 -pal_cache_summary(VCPU *vcpu) {
   1.177 -	struct ia64_pal_retval result;
   1.178 -
   1.179 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.180 -
   1.181 -	return result;
   1.182 -}
   1.183 -
   1.184 -static struct ia64_pal_retval
   1.185 -pal_cache_init(VCPU *vcpu) {
   1.186 +void
   1.187 +pal_emul(struct vcpu *vcpu)
   1.188 +{
   1.189 +	u64 gr28, gr29, gr30, gr31;
   1.190  	struct ia64_pal_retval result;
   1.191  
   1.192 -	INIT_PAL_STATUS_SUCCESS(result);
   1.193 -
   1.194 -	return result;
   1.195 -}
   1.196 -
   1.197 -static struct ia64_pal_retval
   1.198 -pal_cache_info(VCPU *vcpu) {
   1.199 -	struct ia64_pal_retval result;
   1.200 -
   1.201 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.202 -
   1.203 -	return result;
   1.204 -}
   1.205 -
   1.206 -static struct ia64_pal_retval
   1.207 -pal_cache_prot_info(VCPU *vcpu) {
   1.208 -	struct ia64_pal_retval result;
   1.209 -
   1.210 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.211 -
   1.212 -	return result;
   1.213 -}
   1.214 -
   1.215 -static struct ia64_pal_retval
   1.216 -pal_mem_attrib(VCPU *vcpu) {
   1.217 -	struct ia64_pal_retval result;
   1.218 -
   1.219 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.220 -
   1.221 -	return result;
   1.222 -}
   1.223 -
   1.224 -static struct ia64_pal_retval
   1.225 -pal_debug_info(VCPU *vcpu) {
   1.226 -	struct ia64_pal_retval result;
   1.227 -
   1.228 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.229 -
   1.230 -	return result;
   1.231 -}
   1.232 -
   1.233 -static struct ia64_pal_retval
   1.234 -pal_fixed_addr(VCPU *vcpu) {
   1.235 -	struct ia64_pal_retval result;
   1.236 +	vcpu_get_gr_nat(vcpu, 28, &gr28);  //bank1
   1.237  
   1.238 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.239 -
   1.240 -	return result;
   1.241 -}
   1.242 -
   1.243 -static struct ia64_pal_retval
   1.244 -pal_freq_base(VCPU *vcpu) {
   1.245 -	struct ia64_pal_retval result;
   1.246 -	struct ia64_sal_retval isrv;
   1.247 -
   1.248 -	PAL_CALL(result,PAL_FREQ_BASE, 0, 0, 0);
   1.249 -	/*
   1.250 -	 * PAL_FREQ_BASE may not be implemented in some platforms,
   1.251 -	 * call SAL instead.
   1.252 -	 */
   1.253 -	if (result.v0 == 0) {
   1.254 -		SAL_CALL(isrv, SAL_FREQ_BASE, 
   1.255 -		         SAL_FREQ_BASE_PLATFORM, 0, 0, 0, 0, 0, 0);
   1.256 -		result.status = isrv.status;
   1.257 -		result.v0 = isrv.v0;
   1.258 -		result.v1 = result.v2 = 0;
   1.259 -	}
   1.260 -	return result;
   1.261 -}
   1.262 -
   1.263 -static struct ia64_pal_retval
   1.264 -pal_freq_ratios(VCPU *vcpu) {
   1.265 -	struct ia64_pal_retval result;
   1.266 -
   1.267 -	PAL_CALL(result, PAL_FREQ_RATIOS, 0, 0, 0);
   1.268 -	return result;
   1.269 -}
   1.270 -
   1.271 -static struct ia64_pal_retval
   1.272 -pal_halt_info(VCPU *vcpu) {
   1.273 -	struct ia64_pal_retval result;
   1.274 -
   1.275 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.276 -
   1.277 -	return result;
   1.278 -}
   1.279 -
   1.280 -static struct ia64_pal_retval
   1.281 -pal_logical_to_physica(VCPU *vcpu) {
   1.282 -	struct ia64_pal_retval result;
   1.283 -
   1.284 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.285 +	/* FIXME: works only for static calling convention ?  */
   1.286 +	vcpu_get_gr_nat(vcpu, 29, &gr29);
   1.287 +	vcpu_get_gr_nat(vcpu, 30, &gr30); 
   1.288 +	vcpu_get_gr_nat(vcpu, 31, &gr31);
   1.289  
   1.290 -	return result;
   1.291 -}
   1.292 -
   1.293 -static struct ia64_pal_retval
   1.294 -pal_perf_mon_info(VCPU *vcpu) {
   1.295 -	struct ia64_pal_retval result;
   1.296 -
   1.297 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.298 -
   1.299 -	return result;
   1.300 -}
   1.301 -
   1.302 -static struct ia64_pal_retval
   1.303 -pal_proc_get_features(VCPU *vcpu) {
   1.304 -	struct ia64_pal_retval result;
   1.305 -
   1.306 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.307 -
   1.308 -	return result;
   1.309 -}
   1.310 -
   1.311 -static struct ia64_pal_retval
   1.312 -pal_ptce_info(VCPU *vcpu) {
   1.313 -	struct ia64_pal_retval result;
   1.314 -
   1.315 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.316 -
   1.317 -	return result;
   1.318 -}
   1.319 -
   1.320 -static struct ia64_pal_retval
   1.321 -pal_register_info(VCPU *vcpu) {
   1.322 -	struct ia64_pal_retval result;
   1.323 -
   1.324 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.325 -
   1.326 -	return result;
   1.327 -}
   1.328 -
   1.329 -static struct ia64_pal_retval
   1.330 -pal_rse_info(VCPU *vcpu) {
   1.331 -	struct ia64_pal_retval result;
   1.332 -
   1.333 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.334 +	perfc_incrc(vmx_pal_emul);
   1.335 +	result = xen_pal_emulator(gr28, gr29, gr30, gr31);
   1.336  
   1.337 -	return result;
   1.338 -}
   1.339 -
   1.340 -static struct ia64_pal_retval
   1.341 -pal_test_info(VCPU *vcpu) {
   1.342 -	struct ia64_pal_retval result;
   1.343 -
   1.344 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.345 -
   1.346 -	return result;
   1.347 -}
   1.348 -
   1.349 -static struct ia64_pal_retval
   1.350 -pal_vm_summary(VCPU *vcpu) {
   1.351 -	pal_vm_info_1_u_t vminfo1;
   1.352 -	pal_vm_info_2_u_t vminfo2;	
   1.353 -	struct ia64_pal_retval result;
   1.354 -	
   1.355 -	PAL_CALL(result, PAL_VM_SUMMARY, 0, 0, 0);
   1.356 -	if (!result.status) {
   1.357 -		vminfo1.pvi1_val = result.v0;
   1.358 -		vminfo1.pal_vm_info_1_s.max_itr_entry = NITRS -1;
   1.359 -		vminfo1.pal_vm_info_1_s.max_dtr_entry = NDTRS -1;
   1.360 -		result.v0 = vminfo1.pvi1_val;
   1.361 -		vminfo2.pal_vm_info_2_s.impl_va_msb = GUEST_IMPL_VA_MSB;
   1.362 -		vminfo2.pal_vm_info_2_s.rid_size =
   1.363 -		                             current->domain->arch.rid_bits;
   1.364 -		result.v1 = vminfo2.pvi2_val;
   1.365 -	} 
   1.366 -	return result;
   1.367 -}
   1.368 -
   1.369 -static struct ia64_pal_retval
   1.370 -pal_vm_info(VCPU *vcpu) {
   1.371 -	struct ia64_pal_retval result;
   1.372 -
   1.373 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.374 -
   1.375 -	return result;
   1.376 -}
   1.377 -
   1.378 -static struct ia64_pal_retval
   1.379 -pal_vm_page_size(VCPU *vcpu) {
   1.380 -	struct ia64_pal_retval result;
   1.381 -
   1.382 -	INIT_PAL_STATUS_UNIMPLEMENTED(result);
   1.383 -
   1.384 -	return result;
   1.385 +	vcpu_set_gr(vcpu, 8, result.status, 0);
   1.386 +	vcpu_set_gr(vcpu, 9, result.v0, 0);
   1.387 +	vcpu_set_gr(vcpu, 10, result.v1, 0);
   1.388 +	vcpu_set_gr(vcpu, 11, result.v2, 0);
   1.389  }
   1.390  
   1.391  void
   1.392 -pal_emul(VCPU *vcpu) {
   1.393 -	u64 gr28;
   1.394 -	struct ia64_pal_retval result;
   1.395 -
   1.396 -	vcpu_get_gr_nat(vcpu,28,&gr28);  //bank1
   1.397 -
   1.398 -	perfc_incrc(vmx_pal_emul);
   1.399 -	switch (gr28) {
   1.400 -		case PAL_CACHE_FLUSH:
   1.401 -			result = pal_cache_flush(vcpu);
   1.402 -			break;
   1.403 -
   1.404 -		case PAL_PREFETCH_VISIBILITY:
   1.405 -			result = pal_prefetch_visibility(vcpu);
   1.406 -			break;
   1.407 -
   1.408 -		case PAL_VM_TR_READ:
   1.409 -			result = pal_vm_tr_read(vcpu);
   1.410 -			break;
   1.411 -
   1.412 -		case PAL_HALT:
   1.413 -			result = pal_halt(vcpu);
   1.414 -			break;
   1.415 -
   1.416 -		case PAL_HALT_LIGHT:
   1.417 -			result = pal_halt_light(vcpu);
   1.418 -			break;
   1.419 -
   1.420 -		case PAL_CACHE_READ:
   1.421 -			result = pal_cache_read(vcpu);
   1.422 -			break;
   1.423 -
   1.424 -		case PAL_CACHE_WRITE:
   1.425 -			result = pal_cache_write(vcpu);
   1.426 -			break;
   1.427 -
   1.428 -		case PAL_PLATFORM_ADDR:
   1.429 -			result = pal_platform_addr(vcpu);
   1.430 -			break;
   1.431 -
   1.432 -		case PAL_FREQ_RATIOS:
   1.433 -			result = pal_freq_ratios(vcpu);
   1.434 -			break;
   1.435 -
   1.436 -		case PAL_FREQ_BASE:
   1.437 -			result = pal_freq_base(vcpu);
   1.438 -			break;
   1.439 -
   1.440 -		case PAL_BUS_GET_FEATURES :
   1.441 -			result = pal_bus_get_features(vcpu);
   1.442 -			break;
   1.443 -
   1.444 -		case PAL_CACHE_SUMMARY :
   1.445 -			result = pal_cache_summary(vcpu);
   1.446 -			break;
   1.447 -
   1.448 -		case PAL_CACHE_INIT :
   1.449 -			result = pal_cache_init(vcpu);
   1.450 -			break;
   1.451 -
   1.452 -		case PAL_CACHE_INFO :
   1.453 -			result = pal_cache_info(vcpu);
   1.454 -			break;
   1.455 -
   1.456 -		case PAL_CACHE_PROT_INFO :
   1.457 -			result = pal_cache_prot_info(vcpu);
   1.458 -			break;
   1.459 -
   1.460 -		case PAL_MEM_ATTRIB :
   1.461 -			result = pal_mem_attrib(vcpu);
   1.462 -			break;
   1.463 -
   1.464 -		case PAL_DEBUG_INFO :
   1.465 -			result = pal_debug_info(vcpu);
   1.466 -			break;
   1.467 -
   1.468 -		case PAL_FIXED_ADDR :
   1.469 -			result = pal_fixed_addr(vcpu);
   1.470 -			break;
   1.471 -
   1.472 -		case PAL_HALT_INFO :
   1.473 -			result = pal_halt_info(vcpu);
   1.474 -			break;
   1.475 -
   1.476 -		case PAL_LOGICAL_TO_PHYSICAL :
   1.477 -			result = pal_logical_to_physica(vcpu);
   1.478 -			break;
   1.479 -
   1.480 -		case PAL_PERF_MON_INFO :
   1.481 -			result = pal_perf_mon_info(vcpu);
   1.482 -			break;
   1.483 -
   1.484 -		case  PAL_PROC_GET_FEATURES:
   1.485 -			result = pal_proc_get_features(vcpu);
   1.486 -			break;
   1.487 -
   1.488 -		case PAL_PTCE_INFO :
   1.489 -			result = pal_ptce_info(vcpu);
   1.490 -			break;
   1.491 -
   1.492 -		case PAL_REGISTER_INFO :
   1.493 -			result = pal_register_info(vcpu);
   1.494 -			break;
   1.495 -
   1.496 -		case PAL_RSE_INFO :
   1.497 -			result = pal_rse_info(vcpu);
   1.498 -			break;
   1.499 -
   1.500 -		case PAL_TEST_PROC :
   1.501 -			result = pal_test_info(vcpu);
   1.502 -			break;
   1.503 -
   1.504 -		case PAL_VM_SUMMARY :
   1.505 -			result = pal_vm_summary(vcpu);
   1.506 -			break;
   1.507 -
   1.508 -		case PAL_VM_INFO :
   1.509 -			result = pal_vm_info(vcpu);
   1.510 -			break;
   1.511 -
   1.512 -		case PAL_VM_PAGE_SIZE :
   1.513 -			result = pal_vm_page_size(vcpu);
   1.514 -			break;
   1.515 -
   1.516 -		default:
   1.517 -			panic_domain(vcpu_regs(vcpu),"pal_emul(): guest "
   1.518 -			             "call unsupported pal" );
   1.519 -	}
   1.520 -	set_pal_result(vcpu, result);
   1.521 -}
   1.522 -
   1.523 -void
   1.524 -sal_emul(VCPU *v) {
   1.525 +sal_emul(struct vcpu *v)
   1.526 +{
   1.527  	struct sal_ret_values result;
   1.528  	result = sal_emulator(vcpu_get_gr(v, 32), vcpu_get_gr(v, 33),
   1.529  	                      vcpu_get_gr(v, 34), vcpu_get_gr(v, 35),
   1.530  	                      vcpu_get_gr(v, 36), vcpu_get_gr(v, 37),
   1.531  	                      vcpu_get_gr(v, 38), vcpu_get_gr(v, 39));
   1.532 -	set_sal_result(v, result);	
   1.533 +
   1.534 +	vcpu_set_gr(v, 8, result.r8, 0);
   1.535 +	vcpu_set_gr(v, 9, result.r9, 0);
   1.536 +	vcpu_set_gr(v, 10, result.r10, 0);
   1.537 +	vcpu_set_gr(v, 11, result.r11, 0);
   1.538  }
     2.1 --- a/xen/arch/ia64/xen/fw_emul.c	Wed Oct 18 22:06:23 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/fw_emul.c	Wed Oct 18 22:06:38 2006 -0600
     2.3 @@ -26,9 +26,11 @@
     2.4  #include <public/sched.h>
     2.5  #include "hpsim_ssc.h"
     2.6  #include <asm/vcpu.h>
     2.7 +#include <asm/vmx_vcpu.h>
     2.8  #include <asm/dom_fw.h>
     2.9  #include <asm/uaccess.h>
    2.10  #include <xen/console.h>
    2.11 +#include <xen/hypercall.h>
    2.12  
    2.13  extern unsigned long running_on_sim;
    2.14  
    2.15 @@ -173,6 +175,10 @@ xen_pal_emulator(unsigned long index, u6
    2.16  		break;
    2.17  	    case PAL_FREQ_BASE:
    2.18  		status = ia64_pal_freq_base(&r9);
    2.19 +		if (status == PAL_STATUS_UNIMPLEMENTED) {
    2.20 +			status = ia64_sal_freq_base(0, &r9, &r10);
    2.21 +			r10 = 0;
    2.22 +		}
    2.23  		break;
    2.24  	    case PAL_PROC_GET_FEATURES:
    2.25  		status = ia64_pal_proc_get_features(&r9,&r10,&r11);
    2.26 @@ -215,7 +221,7 @@ xen_pal_emulator(unsigned long index, u6
    2.27  	        {
    2.28  			/* Use xen-specific values.
    2.29  			   hash_tag_id is somewhat random! */
    2.30 -			const pal_vm_info_1_u_t v1 =
    2.31 +			static const pal_vm_info_1_u_t v1 =
    2.32  				{.pal_vm_info_1_s =
    2.33  				 { .vw = 1,
    2.34  				   .phys_add_size = 44,
    2.35 @@ -232,11 +238,12 @@ xen_pal_emulator(unsigned long index, u6
    2.36  				   .num_tc_levels = 1
    2.37  #endif
    2.38  				 }};
    2.39 -			const pal_vm_info_2_u_t v2 =
    2.40 -				{ .pal_vm_info_2_s =
    2.41 -				  { .impl_va_msb = 50,
    2.42 -				    .rid_size = current->domain->arch.rid_bits,
    2.43 -				    .reserved = 0 }};
    2.44 +			pal_vm_info_2_u_t v2;
    2.45 +			v2.pvi2_val = 0;
    2.46 +			v2.pal_vm_info_2_s.rid_size =
    2.47 +				current->domain->arch.rid_bits;
    2.48 +			v2.pal_vm_info_2_s.impl_va_msb =
    2.49 +				VMX_DOMAIN(current) ? GUEST_IMPL_VA_MSB : 50;
    2.50  			r9 = v1.pvi1_val;
    2.51  			r10 = v2.pvi2_val;
    2.52  			status = PAL_STATUS_SUCCESS;
    2.53 @@ -294,9 +301,20 @@ xen_pal_emulator(unsigned long index, u6
    2.54  		status = ia64_pal_register_info(in1, &r9, &r10);
    2.55  		break;
    2.56  	    case PAL_CACHE_FLUSH:
    2.57 -		/* FIXME */
    2.58 -		printk("PAL_CACHE_FLUSH NOT IMPLEMENTED!\n");
    2.59 -		BUG();
    2.60 +		/* Always call Host Pal in int=0 */
    2.61 +		in2 &= ~PAL_CACHE_FLUSH_CHK_INTRS;
    2.62 +
    2.63 +		/*
    2.64 +		 * Call Host PAL cache flush
    2.65 +		 * Clear psr.ic when call PAL_CACHE_FLUSH
    2.66 +		 */
    2.67 +		r10 = in3;
    2.68 +		status = ia64_pal_cache_flush(in1, in2, &r10, &r9);
    2.69 +
    2.70 +		if (status != 0)
    2.71 +			panic_domain(NULL, "PAL_CACHE_FLUSH ERROR, "
    2.72 +			             "status %lx", status);
    2.73 +
    2.74  		break;
    2.75  	    case PAL_PERF_MON_INFO:
    2.76  		{
    2.77 @@ -343,15 +361,26 @@ xen_pal_emulator(unsigned long index, u6
    2.78  	        }
    2.79  		break;
    2.80  	    case PAL_HALT:
    2.81 -		    if (current->domain == dom0) {
    2.82 -			    printf ("Domain0 halts the machine\n");
    2.83 -			    console_start_sync();
    2.84 -			    (*efi.reset_system)(EFI_RESET_SHUTDOWN,0,0,NULL);
    2.85 -		    }
    2.86 -		    else
    2.87 -			    domain_shutdown (current->domain,
    2.88 -					     SHUTDOWN_poweroff);
    2.89 -		    break;
    2.90 +		if (current->domain == dom0) {
    2.91 +			printf ("Domain0 halts the machine\n");
    2.92 +			console_start_sync();
    2.93 +			(*efi.reset_system)(EFI_RESET_SHUTDOWN,0,0,NULL);
    2.94 +		}
    2.95 +		else
    2.96 +			domain_shutdown(current->domain, SHUTDOWN_poweroff);
    2.97 +		break;
    2.98 +	    case PAL_HALT_LIGHT:
    2.99 +		if (VMX_DOMAIN(current)) {
   2.100 +			/* Called by VTI.  */
   2.101 +			if (!is_unmasked_irq(current))
   2.102 +				do_sched_op_compat(SCHEDOP_block, 0);
   2.103 +			status = PAL_STATUS_SUCCESS;
   2.104 +		}
   2.105 +		break;
   2.106 +	    case PAL_PLATFORM_ADDR:
   2.107 +		if (VMX_DOMAIN(current))
   2.108 +			status = PAL_STATUS_SUCCESS;
   2.109 +		break;
   2.110  	    default:
   2.111  		printk("xen_pal_emulator: UNIMPLEMENTED PAL CALL %lu!!!!\n",
   2.112  				index);