public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Carsten Otte <cotte@de.ibm.com>
Cc: Avi Kivity <avi@qumranet.com>, kvm <kvm@vger.kernel.org>,
	Olaf Schnapper <os@de.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Hollis Blanchard <hollisb@us.ibm.com>
Subject: Re: [PATCH] libkvm-s390
Date: Mon, 14 Jul 2008 10:34:46 -0500	[thread overview]
Message-ID: <487B7216.4030608@codemonkey.ws> (raw)
In-Reply-To: <1215797386.6014.4.camel@cotte.boeblingen.de.ibm.com>

Carsten Otte wrote:
> This patch makes libkvm build and work on s390. It should be a noop for
> all other architectures.
>   

I'm thinking of spending some time eliminate libkvm altogether in the 
next month or so.  Noone seems to be using it for alternative userspaces 
and the code that interacts with it in QEMU badly needs refactoring.

Dropping the abstraction will probably result in a big drop in lines of 
code and would probably make it more clear anyway.

Regards,

Anthony Liguori

> Signed-off-by: Carsten Otte <cotte@de.ibm.com>
> ---
> Index: kvm-userspace/libkvm/config-s390x.mak
> ===================================================================
> --- /dev/null
> +++ kvm-userspace/libkvm/config-s390x.mak
> @@ -0,0 +1,6 @@
> +
> +LIBDIR := /lib
> +CFLAGS +=
> +CFLAGS += -D__s390x__
> +
> +libkvm-$(ARCH)-objs := libkvm-s390x.o
> Index: kvm-userspace/libkvm/libkvm-s390x.c
> ===================================================================
> --- /dev/null
> +++ kvm-userspace/libkvm/libkvm-s390x.c
> @@ -0,0 +1,98 @@
> +/*
> + * This header is for functions & variables that will ONLY be
> + * used inside libkvm for s390x.
> + * THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE
> + * WITHIN LIBKVM.
> + *
> + * derived from libkvm-powerpc.c
> + *
> + * Copyright 2008 IBM Corporation
> + * Authors:
> + *	Carsten Otte <cotte@de.ibm.com>
> + *
> + * This work is licensed under the GNU LGPL license, version 2.
> + */
> +
> +#include "libkvm.h"
> +#include <errno.h>
> +#include <stdio.h>
> +#include <inttypes.h>
> +
> +int handle_dcr(struct kvm_run *run,  kvm_context_t kvm, int vcpu)
> +{
> +	fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__);
> +	return -1;
> +}
> +
> +int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory,
> +				void **vm_mem)
> +{
> +	fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__);
> +	return -1;
> +}
> +
> +void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start,
> +				 unsigned long len, int log, int writable)
> +{
> +	fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__);
> +	return NULL;
> +}
> +
> +void kvm_show_code(kvm_context_t kvm, int vcpu)
> +{
> +	fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__);
> +}
> +
> +void kvm_show_regs(kvm_context_t kvm, int vcpu)
> +{
> +	struct kvm_regs regs;
> +	int i;
> +
> +	if (kvm_get_regs(kvm, vcpu, &regs))
> +		return;
> +	/*
> +	fprintf(stderr,"guest vcpu #%d\n", vcpu);
> +	fprintf(stderr,"pc:   %016"PRIx64" msr:  %016"PRIx64"\n",
> +	        regs.pc, regs.msr);
> +	fprintf(stderr,"lr:   %016"PRIx64" ctr:  %016"PRIx64"\n",
> +	        regs.lr, regs.ctr);
> +	fprintf(stderr,"srr0: %016"PRIx64" srr1: %016"PRIx64"\n",
> +	        regs.srr0, regs.srr1);
> +	for (i=0; i<32; i+=4)
> +	{
> +		fprintf(stderr, "gpr%02d: %016"PRIx64" %016"PRIx64" %016"PRIx64
> +		        " %016"PRIx64"\n", i,
> +			regs.gpr[i],
> +			regs.gpr[i+1],
> +			regs.gpr[i+2],
> +			regs.gpr[i+3]);
> +	}
> +
> +	fflush(stdout);
> +	*/
> +}
> +
> +int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
> +			 void **vm_mem)
> +{
> +	return 0;
> +}
> +
> +int kvm_arch_create_default_phys_mem(kvm_context_t kvm,
> +					unsigned long phys_mem_bytes,
> +					void **vm_mem)
> +{
> +	return 0;
> +}
> +
> +int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu)
> +{
> +	int ret = 0;
> +
> +	switch (run->exit_reason){
> +	default:
> +		ret = 1;
> +		break;
> +	}
> +	return ret;
> +}
> Index: kvm-userspace/Makefile
> ===================================================================
> --- kvm-userspace.orig/Makefile
> +++ kvm-userspace/Makefile
> @@ -5,7 +5,7 @@ DESTDIR=
>  
>  rpmrelease = devel
>  
> -sane-arch = $(subst i386,x86,$(subst x86_64,x86,$(ARCH)))
> +sane-arch = $(subst i386,x86,$(subst x86_64,x86,$(subst s390x,s390,$(ARCH))))
>  
>  .PHONY: kernel user libkvm qemu bios vgabios extboot clean libfdt
>  
> Index: kvm-userspace/libkvm/kvm-common.h
> ===================================================================
> --- kvm-userspace.orig/libkvm/kvm-common.h
> +++ kvm-userspace/libkvm/kvm-common.h
> @@ -18,8 +18,15 @@
>  
>  /* FIXME: share this number with kvm */
>  /* FIXME: or dynamically alloc/realloc regions */
> +#ifndef __s390x__
>  #define KVM_MAX_NUM_MEM_REGIONS 8u
> +#define MAX_VCPUS 64
> +#else
> +#define KVM_MAX_NUM_MEM_REGIONS 1u
>  #define MAX_VCPUS 16
> +#define LIBKVM_S390_ORIGIN (0UL)
> +#endif
> +
>  
>  /* kvm abi verison variable */
>  extern int kvm_abi;
> Index: kvm-userspace/libkvm/kvm-s390x.h
> ===================================================================
> --- /dev/null
> +++ kvm-userspace/libkvm/kvm-s390x.h
> @@ -0,0 +1,30 @@
> +/*
> + * This header is for functions & variables that will ONLY be
> + * used inside libkvm for s390.
> + * THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE
> + * WITHIN LIBKVM.
> + *
> + * Copyright (C) 2006 Qumranet, Inc.
> + *
> + * Authors:
> + *	Avi Kivity   <avi@qumranet.com>
> + *	Yaniv Kamay  <yaniv@qumranet.com>
> + *
> + * Copyright 2008 IBM Corporation.
> + * Authors:
> + *	Carsten Otte <cotte@de.ibm.com>
> + *
> + * This work is licensed under the GNU LGPL license, version 2.
> + */
> +
> +#ifndef KVM_S390X_H
> +#define KVM_S390X_H
> +
> +#include "kvm-common.h"
> +
> +#define PAGE_SIZE 4096ul
> +#define PAGE_MASK (~(PAGE_SIZE - 1))
> +
> +#define smp_wmb()   asm volatile("" ::: "memory")
> +
> +#endif
> Index: kvm-userspace/libkvm/libkvm.c
> ===================================================================
> --- kvm-userspace.orig/libkvm/libkvm.c
> +++ kvm-userspace/libkvm/libkvm.c
> @@ -48,6 +48,10 @@
>  #include "kvm-powerpc.h"
>  #endif
>  
> +#if defined(__s390x__)
> +#include "kvm-s390x.h"
> +#endif
> +
>  int kvm_abi = EXPECTED_KVM_API_VERSION;
>  int kvm_page_size;
>  
> @@ -88,7 +92,11 @@ int get_free_slot(kvm_context_t kvm)
>  	if (tss_ext > 0)
>  		i = 0;
>  	else
> +#if !defined(__s390x__)
>  		i = 1;
> +#else
> +		i = 0;
> +#endif
>  
>  	for (; i < KVM_MAX_NUM_MEM_REGIONS; ++i)
>  		if (!slots[i].len)
> @@ -392,7 +400,6 @@ int kvm_create(kvm_context_t kvm, unsign
>  	return 0;
>  }
>  
> -
>  #ifdef KVM_CAP_USER_MEMORY
>  
>  void *kvm_create_userspace_phys_mem(kvm_context_t kvm, unsigned long phys_start,
> @@ -410,7 +417,12 @@ void *kvm_create_userspace_phys_mem(kvm_
>  	if (writable)
>  		prot |= PROT_WRITE;
>  
> +#if !defined(__s390x__)
>  	ptr = mmap(NULL, len, prot, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
> +#else
> +	ptr = mmap(LIBKVM_S390_ORIGIN, len, prot | PROT_EXEC,
> +		MAP_FIXED | MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> +#endif
>  	if (ptr == MAP_FAILED) {
>  		fprintf(stderr, "create_userspace_phys_mem: %s", strerror(errno));
>  		return 0;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>   


  parent reply	other threads:[~2008-07-14 15:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-11 17:29 [PATCH] libkvm-s390 Carsten Otte
2008-07-13  8:29 ` Avi Kivity
2008-07-14 11:33   ` Christian Borntraeger
2008-07-14 11:44     ` Avi Kivity
2008-07-14 12:25       ` Christian Borntraeger
2008-07-14 15:34 ` Anthony Liguori [this message]
2008-07-14 17:00   ` Christian Borntraeger
2008-07-14 18:00     ` Anthony Liguori
2008-07-16 15:28 ` [PATCH v2/RFC] libkvm-s390 Christian Borntraeger
2008-07-17 11:08   ` Christian Ehrhardt
2008-07-17 15:28     ` [PATCH v3] libkvm-s390 Christian Borntraeger
2008-07-19  7:56       ` Avi Kivity

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=487B7216.4030608@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=avi@qumranet.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cotte@de.ibm.com \
    --cc=hollisb@us.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=os@de.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox