aboutsummaryrefslogtreecommitdiffstats
path: root/package/uci
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-02-24 18:07:06 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-02-24 18:07:06 +0000
commited5b7b739231eb71b9a793fa05d97d53bdea34ce (patch)
tree6de443f4fff71ca4d457653e7593d5cf5a3a33be /package/uci
parent6990f66861578282f2fab1dbc967077740406fd7 (diff)
downloadupstream-ed5b7b739231eb71b9a793fa05d97d53bdea34ce.tar.gz
upstream-ed5b7b739231eb71b9a793fa05d97d53bdea34ce.tar.bz2
upstream-ed5b7b739231eb71b9a793fa05d97d53bdea34ce.zip
uci: update to git head, reduces quotations in exported config files and fixes delta list handling in the Lua binding
SVN-Revision: 30711
Diffstat (limited to 'package/uci')
-rw-r--r--package/uci/Makefile6
1 files changed, 3 insertions, 3 deletions
diff --git a/package/uci/Makefile b/package/uci/Makefile
index fadcbcd583..dc118e4c51 100644
--- a/package/uci/Makefile
+++ b/package/uci/Makefile
@@ -7,20 +7,20 @@
include $(TOPDIR)/rules.mk
-UCI_VERSION=2011-11-14
+UCI_VERSION=2012-02-24
UCI_RELEASE=1
PKG_NAME:=uci
PKG_VERSION:=$(UCI_VERSION)$(if $(UCI_RELEASE),.$(UCI_RELEASE))
PKG_RELEASE:=1
-PKG_REV:=7289b2d69aaffa9299b47aaaa0da1e9969ace6c1
+PKG_REV:=d3722382bdd467d1c705911450120be75426406f
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=git://nbd.name/uci.git
PKG_SOURCE_SUBDIR:=uci-$(PKG_VERSION)
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_PROTO:=git
-PKG_MIRROR_MD5SUM:=74b0ab930321c4f85f220ff3852e210a
+PKG_MIRROR_MD5SUM:=476039f871b69d756f3b04498130c27e
PKG_BUILD_PARALLEL:=0
n176'>176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
/*
 * vmx_vmcs.c: VMCS management
 * Copyright (c) 2004, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307 USA.
 *
 */

#include <xen/config.h>
#include <xen/init.h>
#include <xen/mm.h>
#include <xen/lib.h>
#include <xen/errno.h>
#include <xen/domain_page.h>
#include <asm/current.h>
#include <asm/cpufeature.h>
#include <asm/processor.h>
#include <asm/msr.h>
#include <asm/vmx.h>
#include <asm/vmx_vioapic.h>
#include <asm/flushtlb.h>
#include <xen/event.h>
#include <xen/kernel.h>
#include <public/io/ioreq.h>
#if CONFIG_PAGING_LEVELS >= 4
#include <asm/shadow_64.h>
#endif
#ifdef CONFIG_VMX

int vmcs_size;

struct vmcs_struct *alloc_vmcs(void)
{
    struct vmcs_struct *vmcs;
    u32 vmx_msr_low, vmx_msr_high;

    rdmsr(MSR_IA32_VMX_BASIC_MSR, vmx_msr_low, vmx_msr_high);
    vmcs_size = vmx_msr_high & 0x1fff;
    vmcs = alloc_xenheap_pages(get_order_from_bytes(vmcs_size));
    memset((char *)vmcs, 0, vmcs_size); /* don't remove this */

    vmcs->vmcs_revision_id = vmx_msr_low;
    return vmcs;
}

static void free_vmcs(struct vmcs_struct *vmcs)
{
    int order;

    order = get_order_from_bytes(vmcs_size);
    free_xenheap_pages(vmcs, order);
}

static int load_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr)
{
    int error;

    if ((error = __vmptrld(phys_ptr))) {
        clear_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags);
        return error;
    }
    set_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags);
    return 0;
}

#if 0
static int store_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr)
{
    /* take the current VMCS */
    __vmptrst(phys_ptr);
    clear_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags);
    return 0;
}
#endif

static inline int construct_vmcs_controls(struct arch_vmx_struct *arch_vmx)
{
    int error = 0;
    void *io_bitmap_a;
    void *io_bitmap_b;

    error |= __vmwrite(PIN_BASED_VM_EXEC_CONTROL,
                       MONITOR_PIN_BASED_EXEC_CONTROLS);

    error |= __vmwrite(VM_EXIT_CONTROLS, MONITOR_VM_EXIT_CONTROLS);

    error |= __vmwrite(VM_ENTRY_CONTROLS, MONITOR_VM_ENTRY_CONTROLS);

    /* need to use 0x1000 instead of PAGE_SIZE */
    io_bitmap_a = (void*) alloc_xenheap_pages(get_order_from_bytes(0x1000));
    io_bitmap_b = (void*) alloc_xenheap_pages(get_order_from_bytes(0x1000));
    memset(io_bitmap_a, 0xff, 0x1000);
    /* don't bother debug port access */
    clear_bit(PC_DEBUG_PORT, io_bitmap_a);
    memset(io_bitmap_b, 0xff, 0x1000);

    error |= __vmwrite(IO_BITMAP_A, (u64) virt_to_phys(io_bitmap_a));
    error |= __vmwrite(IO_BITMAP_B, (u64) virt_to_phys(io_bitmap_b));

    arch_vmx->io_bitmap_a = io_bitmap_a;
    arch_vmx->io_bitmap_b = io_bitmap_b;

    return error;
}

#define GUEST_LAUNCH_DS         0x08
#define GUEST_LAUNCH_CS         0x10
#define GUEST_SEGMENT_LIMIT     0xffffffff
#define HOST_SEGMENT_LIMIT      0xffffffff

struct host_execution_env {
    /* selectors */
    unsigned short ldtr_selector;
    unsigned short tr_selector;
    unsigned short ds_selector;
    unsigned short cs_selector;
    /* limits */
    unsigned short gdtr_limit;
    unsigned short ldtr_limit;
    unsigned short idtr_limit;
    unsigned short tr_limit;
    /* base */
    unsigned long gdtr_base;
    unsigned long ldtr_base;
    unsigned long idtr_base;
    unsigned long tr_base;
    unsigned long ds_base;
    unsigned long cs_base;
#ifdef __x86_64__
    unsigned long fs_base;
    unsigned long gs_base;
#endif
};

static void vmx_map_io_shared_page(struct domain *d)
{
    int i;
    unsigned char e820_map_nr;
    struct e820entry *e820entry;
    unsigned char *p;
    unsigned long mpfn;
    unsigned long gpfn = 0;

    local_flush_tlb_pge();

    mpfn = get_mfn_from_pfn(E820_MAP_PAGE >> PAGE_SHIFT);
    if (mpfn == INVALID_MFN) {
        printk("Can not find E820 memory map page for VMX domain.\n");
        domain_crash(d);
    }

    p = map_domain_page(mpfn);
    if (p == NULL) {
        printk("Can not map E820 memory map page for VMX domain.\n");
        domain_crash(d);
    }

    e820_map_nr = *(p + E820_MAP_NR_OFFSET);
    e820entry = (struct e820entry *)(p + E820_MAP_OFFSET);

    for ( i = 0; i < e820_map_nr; i++ )
    {
        if (e820entry[i].type == E820_SHARED_PAGE)
        {
            gpfn = (e820entry[i].addr >> PAGE_SHIFT);
            break;
        }
    }

    if ( gpfn == 0 ) {
        printk("Can not get io request shared page"
               " from E820 memory map for VMX domain.\n");
        unmap_domain_page(p);
        domain_crash(d);
    }
    unmap_domain_page(p);

    /* Initialise shared page */
    mpfn = get_mfn_from_pfn(gpfn);
    if (mpfn == INVALID_MFN) {
        printk("Can not find io request shared page for VMX domain.\n");
        domain_crash(d);
    }

    p = map_domain_page(mpfn);
    if (p == NULL) {
        printk("Can not map io request shared page for VMX domain.\n");
        domain_crash(d);
    }
    d->arch.vmx_platform.shared_page_va = (unsigned long)p;

    VMX_DBG_LOG(DBG_LEVEL_1, "eport: %x\n", iopacket_port(d));

    clear_bit(iopacket_port(d),
              &d->shared_info->evtchn_mask[0]);
}

#define VCPU_NR_PAGE        0x0009F000
#define VCPU_NR_OFFSET      0x00000800
#define VCPU_MAGIC          0x76637075  /* "vcpu" */

static void vmx_set_vcpu_nr(struct domain *d)
{
    unsigned char *p;
    unsigned long mpfn;
    unsigned int *vcpus;

    mpfn = get_mfn_from_pfn(VCPU_NR_PAGE >> PAGE_SHIFT);
    if (mpfn == INVALID_MFN) {
        printk("Can not get vcpu number page mfn for VMX domain.\n");
        domain_crash_synchronous();
    }

    p = map_domain_page(mpfn);
    if (p == NULL) {
        printk("Can not map vcpu number page for VMX domain.\n");
        domain_crash_synchronous();
    }

    vcpus = (unsigned int *)(p + VCPU_NR_OFFSET);
    if (vcpus[0] != VCPU_MAGIC) {
        printk("Bad vcpus magic, set vcpu number to 1 by default.\n");
        d->arch.vmx_platform.nr_vcpu = 1;
    }

    d->arch.vmx_platform.nr_vcpu = vcpus[1];

    unmap_domain_page(p);
}

static void vmx_setup_platform(struct domain* d)
{
    struct vmx_platform *platform;

    if (!(VMX_DOMAIN(current) && (current->vcpu_id == 0)))
        return;

    vmx_map_io_shared_page(d);
    vmx_set_vcpu_nr(d);

    platform = &d->arch.vmx_platform;
    pic_init(&platform->vmx_pic,  pic_irq_request, 
             &platform->interrupt_request);
    register_pic_io_hook();

    if ( vmx_apic_support(d) ) {
        spin_lock_init(&d->arch.vmx_platform.round_robin_lock);
        vmx_vioapic_init(d);
    }
}

static void vmx_set_host_env(struct vcpu *v)
{
    unsigned int tr, cpu, error = 0;
    struct host_execution_env host_env;
    struct Xgt_desc_struct desc;

    cpu = smp_processor_id();
    __asm__ __volatile__ ("sidt  (%0) \n" :: "a"(&desc) : "memory");
    host_env.idtr_limit = desc.size;
    host_env.idtr_base = desc.address;
    error |= __vmwrite(HOST_IDTR_BASE, host_env.idtr_base);

    __asm__ __volatile__ ("sgdt  (%0) \n" :: "a"(&desc) : "memory");
    host_env.gdtr_limit = desc.size;
    host_env.gdtr_base = desc.address;
    error |= __vmwrite(HOST_GDTR_BASE, host_env.gdtr_base);

    __asm__ __volatile__ ("str  (%0) \n" :: "a"(&tr) : "memory");
    host_env.tr_selector = tr;
    host_env.tr_limit = sizeof(struct tss_struct);
    host_env.tr_base = (unsigned long) &init_tss[cpu];
    error |= __vmwrite(HOST_TR_SELECTOR, host_env.tr_selector);
    error |= __vmwrite(HOST_TR_BASE, host_env.tr_base);
}

static void vmx_do_launch(struct vcpu *v)
{
/* Update CR3, GDT, LDT, TR */
    unsigned int  error = 0;
    unsigned long cr0, cr4;
    u64     host_tsc;

    if (v->vcpu_id == 0)
        vmx_setup_platform(v->domain);

    __asm__ __volatile__ ("mov %%cr0,%0" : "=r" (cr0) : );

    error |= __vmwrite(GUEST_CR0, cr0);
    cr0 &= ~X86_CR0_PG;
    error |= __vmwrite(CR0_READ_SHADOW, cr0);
    error |= __vmwrite(CPU_BASED_VM_EXEC_CONTROL,
                       MONITOR_CPU_BASED_EXEC_CONTROLS);

    __asm__ __volatile__ ("mov %%cr4,%0" : "=r" (cr4) : );

#ifdef __x86_64__
    error |= __vmwrite(GUEST_CR4, cr4 & ~X86_CR4_PSE);
#else
    error |= __vmwrite(GUEST_CR4, cr4);
#endif

#ifdef __x86_64__
    cr4 &= ~(X86_CR4_PGE | X86_CR4_VMXE | X86_CR4_PAE);
#else
    cr4 &= ~(X86_CR4_PGE | X86_CR4_VMXE);
#endif
    error |= __vmwrite(CR4_READ_SHADOW, cr4);

    vmx_stts();

    if(vmx_apic_support(v->domain))
        vlapic_init(v);

    vmx_set_host_env(v);
    init_ac_timer(&v->arch.arch_vmx.hlt_timer, hlt_timer_fn, v, v->processor);

    error |= __vmwrite(GUEST_LDTR_SELECTOR, 0);
    error |= __vmwrite(GUEST_LDTR_BASE, 0);
    error |= __vmwrite(GUEST_LDTR_LIMIT, 0);

    error |= __vmwrite(GUEST_TR_BASE, 0);
    error |= __vmwrite(GUEST_TR_LIMIT, 0xff);

    __vmwrite(GUEST_CR3, pagetable_get_paddr(v->domain->arch.phys_table));
    __vmwrite(HOST_CR3, pagetable_get_paddr(v->arch.monitor_table));
    __vmwrite(HOST_RSP, (unsigned long)get_stack_bottom());

    v->arch.schedule_tail = arch_vmx_do_resume;
    /* init guest tsc to start from 0 */
    rdtscll(host_tsc);
    v->arch.arch_vmx.tsc_offset = 0 - host_tsc;
    set_tsc_shift (v, &v->domain->arch.vmx_platform.vmx_pit);
}

/*
 * Initially set the same environement as host.
 */
static inline int construct_init_vmcs_guest(cpu_user_regs_t *regs)
{
    int error = 0;
    union vmcs_arbytes arbytes;
    unsigned long dr7;
    unsigned long eflags;

    /* MSR */
    error |= __vmwrite(VM_EXIT_MSR_LOAD_ADDR, 0);
    error |= __vmwrite(VM_EXIT_MSR_STORE_ADDR, 0);

    error |= __vmwrite(VM_EXIT_MSR_STORE_COUNT, 0);
    error |= __vmwrite(VM_EXIT_MSR_LOAD_COUNT, 0);
    error |= __vmwrite(VM_ENTRY_MSR_LOAD_COUNT, 0);
    /* interrupt */
    error |= __vmwrite(VM_ENTRY_INTR_INFO_FIELD, 0);
    /* mask */
    error |= __vmwrite(CR0_GUEST_HOST_MASK, -1UL);
    error |= __vmwrite(CR4_GUEST_HOST_MASK, -1UL);

    error |= __vmwrite(PAGE_FAULT_ERROR_CODE_MASK, 0);
    error |= __vmwrite(PAGE_FAULT_ERROR_CODE_MATCH, 0);

    /* TSC */
    error |= __vmwrite(CR3_TARGET_COUNT, 0);

    /* Guest Selectors */
    error |= __vmwrite(GUEST_ES_SELECTOR, GUEST_LAUNCH_DS);
    error |= __vmwrite(GUEST_SS_SELECTOR, GUEST_LAUNCH_DS);
    error |= __vmwrite(GUEST_DS_SELECTOR, GUEST_LAUNCH_DS);
    error |= __vmwrite(GUEST_FS_SELECTOR, GUEST_LAUNCH_DS);
    error |= __vmwrite(GUEST_GS_SELECTOR, GUEST_LAUNCH_DS);
    error |= __vmwrite(GUEST_CS_SELECTOR, GUEST_LAUNCH_CS);

    /* Guest segment bases */
    error |= __vmwrite(GUEST_ES_BASE, 0);
    error |= __vmwrite(GUEST_SS_BASE, 0);
    error |= __vmwrite(GUEST_DS_BASE, 0);
    error |= __vmwrite(GUEST_FS_BASE, 0);
    error |= __vmwrite(GUEST_GS_BASE, 0);
    error |= __vmwrite(GUEST_CS_BASE, 0);

    /* Guest segment Limits */
    error |= __vmwrite(GUEST_ES_LIMIT, GUEST_SEGMENT_LIMIT);
    error |= __vmwrite(GUEST_SS_LIMIT, GUEST_SEGMENT_LIMIT);
    error |= __vmwrite(GUEST_DS_LIMIT, GUEST_SEGMENT_LIMIT);
    error |= __vmwrite(GUEST_FS_LIMIT, GUEST_SEGMENT_LIMIT);
    error |= __vmwrite(GUEST_GS_LIMIT, GUEST_SEGMENT_LIMIT);
    error |= __vmwrite(GUEST_CS_LIMIT, GUEST_SEGMENT_LIMIT);

    /* Guest segment AR bytes */
    arbytes.bytes = 0;
    arbytes.fields.seg_type = 0x3;          /* type = 3 */
    arbytes.fields.s = 1;                   /* code or data, i.e. not system */
    arbytes.fields.dpl = 0;                 /* DPL = 3 */
    arbytes.fields.p = 1;                   /* segment present */
    arbytes.fields.default_ops_size = 1;    /* 32-bit */
    arbytes.fields.g = 1;
    arbytes.fields.null_bit = 0;            /* not null */

    error |= __vmwrite(GUEST_ES_AR_BYTES, arbytes.bytes);