All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@amd.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Keir Fraser <keir.fraser@eu.citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH 1/2] xl: add cpuid parameter
Date: Fri, 27 Aug 2010 14:56:54 +0200	[thread overview]
Message-ID: <4C77B616.30900@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]

Hi,

this one adds a cpuid parameter into libxl_domain_build_info and uses 
it's content while setting up the domain. This is a placeholder for now, 
since the parsing is only implemented in the next patch.
Please review, I am especially interested if I got the IDL stuff right.

Regards,
Andre.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>

-- 
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 448-3567-12

[-- Attachment #2: 0001-introduce-cpuid-interface-to-domain-build.patch --]
[-- Type: text/x-patch, Size: 4204 bytes --]

>From 73b3800344ba977de88cd79a3d7c3bfd558fd307 Mon Sep 17 00:00:00 2001
From: Andre Przywara <andre.przywara@amd.com>
Date: Tue, 24 Aug 2010 09:35:51 +0200
Subject: [PATCH 1/2] introduce cpuid interface to domain build

---
 tools/libxl/libxl.c      |   14 ++++++++++++++
 tools/libxl/libxl.h      |    6 ++++++
 tools/libxl/libxl.idl    |    2 ++
 tools/libxl/libxl_dom.c  |    6 ++++++
 tools/libxl/xl_cmdimpl.c |    1 +
 5 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 099d82e..da9c7fd 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -98,6 +98,20 @@ void libxl_key_value_list_destroy(libxl_key_value_list kvl)
     free(kvl);
 }
 
+void libxl_cpuid_destroy(libxl_cpuid_type *cpuid)
+{
+    int i, j;
+
+    if (cpuid == NULL)
+        return;
+    for (i = 0; cpuid[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++) {
+        for (j = 0; j < 4; j++)
+            if (cpuid[i].policy[j] != NULL)
+                free(cpuid[i].policy[j]);
+    }
+    free(cpuid);
+}
+
 /******************************************************************************/
 
 int libxl_domain_make(libxl_ctx *ctx, libxl_domain_create_info *info,
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index f6480fb..b8fa8ca 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -178,6 +178,11 @@ typedef enum {
     NICTYPE_VIF,
 } libxl_nic_type;
 
+typedef struct {
+    uint32_t input[2];
+    char *policy[4];
+} libxl_cpuid_type;
+
 #define LIBXL_PCI_FUNC_ALL (~0U)
 
 #include "_libxl_types.h"
@@ -237,6 +242,7 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, libxl_domain_create_in
 void libxl_string_list_destroy(libxl_string_list sl);
 void libxl_key_value_list_destroy(libxl_key_value_list kvl);
 void libxl_file_reference_destroy(libxl_file_reference *f);
+void libxl_cpuid_destroy(libxl_cpuid_type *cpuid);
 
 /*
  * Run the configured bootloader for a PV domain and update
diff --git a/tools/libxl/libxl.idl b/tools/libxl/libxl.idl
index f59950d..dc988d5 100644
--- a/tools/libxl/libxl.idl
+++ b/tools/libxl/libxl.idl
@@ -11,6 +11,7 @@ libxl_console_consback = Builtin("console_consback")
 libxl_console_constype = Builtin("console_constype")
 libxl_disk_phystype = Builtin("disk_phystype")
 libxl_nic_type = Builtin("nic_type")
+libxl_cpuid_type = Builtin("cpuid_type", destructor_fn="libxl_cpuid_destroy")
 
 libxl_string_list = Builtin("string_list", destructor_fn="libxl_string_list_destroy")
 libxl_key_value_list = Builtin("key_value_list", destructor_fn="libxl_key_value_list_destroy")
@@ -97,6 +98,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
     ("shadow_memkb",    uint32),
     ("disable_migrate", bool),
     ("kernel",          libxl_file_reference),
+    ("cpuid",           Reference(libxl_cpuid_type)),
     ("hvm",             integer),
     ("u", KeyedUnion(None, "hvm",
                 [("hvm", "%s", Struct(None,
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index a07bea7..ec4e15f 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -91,9 +91,15 @@ int build_post(libxl_ctx *ctx, uint32_t domid,
     xs_transaction_t t;
     char **ents;
     int i;
+    char *cpuid_res[4];
 
 #if defined(__i386__) || defined(__x86_64__)
     xc_cpuid_apply_policy(ctx->xch, domid);
+    if (info->cpuid != NULL) {
+        for (i = 0; info->cpuid[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++)
+            xc_cpuid_set(ctx->xch, domid, info->cpuid[i].input,
+                         (const char**)(info->cpuid[i].policy), cpuid_res);
+    }
 #endif
 
     ents = libxl_calloc(&gc, 12 + (info->max_vcpus * 2) + 2, sizeof(char *));
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index ae4fcc3..0fa516b 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -268,6 +268,7 @@ static void init_build_info(libxl_domain_build_info *b_info, libxl_domain_create
     b_info->max_memkb = 32 * 1024;
     b_info->target_memkb = b_info->max_memkb;
     b_info->disable_migrate = 0;
+    b_info->cpuid = NULL;
     if (c_info->hvm) {
         b_info->shadow_memkb = 0; /* Set later */
         b_info->video_memkb = 8 * 1024;
-- 
1.6.4


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2010-08-27 12:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-27 12:56 Andre Przywara [this message]
2010-08-27 14:07 ` [PATCH 1/2] xl: add cpuid parameter Gianni Tedesco
2010-08-27 14:51   ` Ian Campbell
2010-08-27 14:56     ` Gianni Tedesco
2010-08-27 15:07       ` Ian Campbell
2010-08-27 15:36         ` Ian Campbell
2010-08-31 15:35         ` Gianni Tedesco
2010-08-27 14:59     ` Ian Campbell

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=4C77B616.30900@amd.com \
    --to=andre.przywara@amd.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.