Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/arch/x86/kvm/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 21 kB image not shown  

SSL ioapic.c   Sprache: C

 
/*
 *  Copyright (C) 2001  MandrakeSoft S.A.
 *  Copyright 2010 Red Hat, Inc. and/or its affiliates.
 *
 *    MandrakeSoft S.A.
 *    43, rue d'Aboukir
 *    75002 Paris - France
 *    http://www.linux-mandrake.com/
 *    http://www.mandrakesoft.com/
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 *  Yunhong Jiang <yunhong.jiang@intel.com>
 *  Yaozu (Eddie) Dong <eddie.dong@intel.com>
 *  Based on Xen 3.1 code.
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/kvm_host.h>
#include <linux/kvm.h>
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/smp.h>
#include <linux/hrtimer.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/export
##include<linuxkvm_host
linux.hjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
#int,
#include asmjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

#include  | );
 lapic
  :
.

static;
 :

static  =(> -0) >>;
          struct kvm_ioapic *ioapic,
          int trigger_mode,
 intjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19

 unsigned ( kvm_ioapic)
{
 unsigned=>  x1

 redir_contentxffffffff
case:
  result
  |IOAPIC_VERSION_ID  xff
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

  (>..,KVM_MAX_VCPU_IDS
   (struct i);
  result = ((ioapic-  ( *ioapic)
  break;

 default:
  {
   u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
 u64  ~ULL

 if <IOAPIC_NUM_PINS
 kvm_rtc_eoi_tracking_restore_all)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

    redir_content = ioapic->redirtbl[indexkvm_ioapic = >kvm-.;
 }

   result = (ioapic->ioregsel & 0x1) ?
  ( > 3)&0 :
       redir_content & 0xffffffff;
  break
  } f((vcpuNULLAPIC_DEST_NOSHORT,
 }

 return result;
}

static void   (!!e-fields)
{
 ioapic- =(vcpu-, dest_map-);
  ( ==old_val
}

static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *

static dest_map-[vcpu-] = >fields;
{
 if (WARN_ON(ioapic->rtc_status.pending_eoi < 0  elsejava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  kvm_rtc_eoi_tracking_restore_all)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
}

static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu)
{
 bool, old_val;
 struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;
 struct dest_map *dest_map = &ioapic->rtc_status.dest_map;
 union

s kvm_ioapicioapicvcpu->arch;
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    >.dest_id
   (!!e-fields))java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
 return

 new_val = kvm_apic_pending_eoi(vcpu,java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 old_val = test_bit

 if (new_val == old_val)
  return;

 if(new_val{
  __set_bit(vcpu->vcpu_id, dest_map->map);
  dest_map-
  >rtc_status++;
 } else {
  __clear_bit(vcpu->vcpu_id, dest_map->kvm_for_each_vcpu,, ioapic-)
  ioapic->rtc_statuspending_eoi--
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 }
}

void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu *vcpu)
{
 struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;

 pin_lock>lock
 __rtc_irq_eoi_tracking_restore_one
 spin_unlock(&ioapic-lock;
}

static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic)
{
 struct  ( ==dest_map-[vcpu-])&java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
  long i

 if (RTC_GSI -ioapic-.pending_eoi
 eturn

java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
kvm_for_each_vcpu,vcpuioapic-kvm
     __rtc_irq_eoi_tracking_restore_one(vcpujava.lang.StringIndexOutOfBoundsException: Range [44, 45) out of bounds for length 1
}

static void rtc_irq_eoi(struct kvm_ioapic
   int
{
 struct static ioapic_lazy_update_eoi  *, int)

 /* RTC special handling */
iftest_bit>vcpu_iddest_map->) &
     (vector == dest_map->vectors[vcpu->vcpu_id]) &&
    ((vcpu-,
  if!(vcpuNULLA,
  --  entry-.dest_id
 rtc_status_pending_eoi_check_validioapic)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45

}

static ;
{
 
   java.lang.StringIndexOutOfBoundsException: Range [4, 5) out of bounds for length 4

 return false  
}

static  ioapic_lazy_update_eoikvm_ioapic, int )
{
 unsigned java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
 struct *;
 union kvm_ioapic_redirect_entry *entry = &ioapic- intboolline_status

 u32 =  <irq
   (kvm_apic_match_dest(, , APIC_DEST_NOSHORT,
      entry->java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
      = entry.trig_mode=IOAPIC_EDGE_TRIG
  
    (irq_level

  /*
 * If no longer has pending EOI in LAPICs, update
 * EOI for this vector.
 */

  * triggered,  * to receive the EOI.  In   * pendingjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  * this   * to   * us if the interrupt is    * RTC is special: it is edge-triggered  * if it has  * interrupts lead to   * EOI manually    & java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
   ;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static ( kvm_ioapic, unsignedint,
  int irq_level,return;
{
 unionstatic kvm_ioapic_inject_all kvm_ioapicioapic long)
   idx
 u32rtc_irq_eoi_tracking_reset);
 int edge, ret for_each_set_bitidxirr )

 entry 
  = entry. =)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

if)
  ioapic-dest_map  >rtc_status;
  ret =  unione
  ;
 }(&>lock

 
 * AMD SVM AVIC accelerate EOI write iff the interrupt is edge
 * triggered, in which case the in-kernel IOAPIC will not be able
 * to receive the EOI.  In this case, we do a lazy update of the
 * pending EOI when trying to set IOAPIC irq.
 */

 if (edge &
  ioapic_lazy_update_eoi(ioapic, irq);

 /*
 * Return 0 for coalesced interrupts; for edge-triggered interrupts,
 * this only happens if a previous edge has not been delivered due
 * to masking.  For level interrupts, the remote_irr field tells
 * us if the interrupt is waiting for an EOI.
 *
 * RTC is special: it is edge-triggered, but userspace likes to know
 * if it has been already ack-ed via EOI because coalesced RTC
 * interrupts lead to time drift in Windows guests.  So we track
 * EOI manually for the RTC interrupt.
 */

 }
  rtc_irq_check_coalesced(ioapic
  ret = 0;
  goto           struct kvm_irq_mask_notifier *kimn{
 }

 old_irr
 ioapic->irr |=         bool mask{
 if ( int idx,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ioapic- bool mask_before union  int old_remote_irr, old_delivery_status, old_dest_id, old_dest_mode;
  if  case IOAPIC_REG_VERSION  /* Writes are ignored. */  break;
   ret c ioapic-> = (val> 2)  0;
   gotoout;
  }
 }

 ret = ioapic_service break

out:
 trace_kvm_ioapic_set_irq default:
 return  index ioapic-ioregsel -0) >> 1java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
}

staticvoid(structkvm_ioapic*ioapicunsigned irr
{
 u32 read-only */

 rtc_irq_eoi_tracking_reset);
  old_delivery_status =e-.delivery_status
 (, idx1 true);

 kvm_rtc_eoi_tracking_restore_all(ioapic);
}


void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, ulong *ioapic_handled_vectors)e-.;
{
 struct> =0;
 struct e-bits()  < 3java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
 union kvm_ioapic_redirect_entry
  >fields =old_remote_irrjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

 spin_lock(&ioapic->lock);

/java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 if (test_bit(vcpu->vcpu_id, dest_map->map))
  _ /java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
     ioapic_handled_vectors);

 for (index   * be cleared by IOAPIC hardware when   * as edge-triggered.   * explicit EOI on IOAPICs  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    ioapic-[ndex
  (>fields=  |
      kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC, index) ||
      index == RTC_GSI) {
  u16 = kvm_lapic_irq_dest_mode!>fields);

   kvm_scan_ioapic_irq(vcpu, e->fields.dest_id, dm,
       >fields, ioapic_handled_vectors);
  }
 }
 spin_unlock(&ioapic->lock);
}

void kvm_arch_post_irq_ack_notifier_list_update(struct kvm *kvm)
{
 if (!ioapic_in_kernel(kvm    * Linux guest as a oneshot     * case the guest acknowledges the interrupt to the    * its threaded irq handler, i.e. after the EOI but before    * unmasking, so at the time of unmasking    * already down but our pending irr    * cases, injecting this pending interrupt to the    * buggy: the guest will receive an    *
    * through    *
 kvm_make_scan_ioapic_request(  * registered for this irq), then unconditionally inject    * pending interrupt into the    * an interrupt, although may java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

kvm_register_irq_mask_notifierkvmkvm  irq
        struct kvm_irq_mask_notifier irq
{
 struct kvm_ioapic *ioapic = kvm->arch.  irq =fields <;

 mutex_lockfalse
;
  irq.shorthand;
(kvm-)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}
 )
 (struct,  ,
          struct kvm_irq_mask_notifier *     ! >.dest_id
{
 mutex_lock     * keep 
hlist_del_rcu>link
 mutex_unlock irq java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
 synchronize_srcu(&kvm- vcpu_bitmap;
}

 kvm_fire_mask_notifiersstruct kvmunsigned,unsignedpin
   else
{
.vioapic
 struct kvm_irq_mask_notifier}
 int idx, gsi;

 idx = srcu_read_lock(&kvm->irq_srcu); breakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
gsi kvm_irq_map_chip_pinkvm, pin;
 if (gsi != -1)
  hlist_for_each_entry_rcu(kimn,
 ifkimn-> =gsijava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
  
 srcu_read_unlock |
}

static      entry-remote_irr)

 unsigned java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 bool, ;
 union .dest_mode(!>fields;
 int. =>fieldsjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
 DECLARE_BITMAP(.level

 switchioapic->ioregsel) java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
 case IOAPIC_REG_VERSION:
  /* Writes are ignored. */
  break;

 case IOAPIC_REG_APIC_ID:
  ioapic->id = (val >> 24) & 0xf;
  break;

  IOAPIC_REG_ARB_ID
  break;

 :
  index = /*

if (index >= IOAPIC_NUM_PINS)
return;
index = array_index_nospec(index, IOAPIC_NUM_PINS);
e = &ioapic->redirtbl[index];
mask_before = e->fields.mask;
/* Preserve read-only fields */

  old_remote_irr = e->fields.remote_irr;
  =>fieldsdelivery_status
   = e-.dest_id
  old_dest_mode = e->fields  /
  if (ioapic->ioregsel & 1) {
   > & 0xffffffff
     =(ioapic-, , irqe
  }    &ioapic-rtc_statusdest_map
   e->bits &=  >rtc_status =( <0    ret
   e- =(ioapic-kvm NULL&, NULL
  }
  e->fields.remote_irr = old_remote_irr;
  e->fields. = old_delivery_status

  /*
 * Some OSes (Linux, Xen) assume that Remote IRR bit will
 * be cleared by IOAPIC hardware when the entry is configured
 * as edge-triggered. This behavior is used to simulate an
 * explicit EOI on IOAPICs that don't have the EOI register.
 */

  if (e->fields.trig_mode == IOAPIC_EDGE_TRIG)
  e-fields.emote_irr=0

  mask_after 
  if (mask_before != mask_after)
   kvm_fire_mask_notifiers(ioapic->
 int kvm_ioapic_set_irqstruct *e,struct  *,
 ioapic- &1<index !-fields &!>fieldsremote_irr java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
   /*
 * Pending status in irr may be outdated: the IRQ line may have
 * already been deasserted by a device while the IRQ was masked.
 * This occurs, for instance, if the interrupt is handled in a
 * Linux guest as a oneshot interrupt (IRQF_ONESHOT). In this
 * case the guest acknowledges the interrupt to the device in
 * its threaded irq handler, i.e. after the EOI but before
 * unmasking, so at the time of unmasking the IRQ line is
 * already down but our pending irr bit is still set. In such
 * cases, injecting this pending interrupt to the guest is
 * buggy: the guest will receive an extra unwanted interrupt.
 *
 * So we need to check here if the IRQ is actually still pending.
 * As we are generally not able to probe the IRQ line status
 * directly, we do it through irqfd resampler. Namely, we clear
 * the pending status and notify the resampler that this interrupt
 * is done, without actually injecting it into the guest. If the
 * IRQ line is actually already deasserted, we are done. If it is
 * still asserted, a new interrupt will be shortly triggered
 * through irqfd and injected into the guest.
 *
 * If, however, it's not possible to resample (no irqfd resampler
 * registered for this irq), then unconditionally inject this
 * pending interrupt into the guest, so the guest will not miss
 * an interrupt, although may get an extra unwanted interrupt.
 */

   if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    ioapic->irr java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
   else
    ioapic_service   eoi_injectwork)
  }
 ife-. =) {
   struct kvm_lapic_irq irq;

   irq.vector = e->fields.vector;
  .delivery_mode e-.delivery_mode<8java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
   irq.  kvm_ioapic_redirect_entry =>[ijava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
       kvm_lapic_irq_dest_mode(!!e- ;
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 irq  fields
   irq. (, ,)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
   irq.  kvm_ioapic_update_eoi_one kvm_vcpu,
   irq.msi_redir_hint = false;
   bitmap_zero(vcpu_bitmap, KVM_MAX_VCPUS);
   kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,
       vcpu_bitmap);
   if (old_dest_mode != e->fields.dest_mode ||
       old_dest_id != e->fields.dest_id) {
   /*
 * Update vcpu_bitmap with vcpus specified in
 * the previous request as well. This is done to
 * keep ioapic_handled_vectors synchronized.
 */

    irq.dest_id = old_dest_id;
    irqstruct * =>arch;
       (
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    kvm_bitmap_or_dest_vcpus(  * to notifiers if the same  * is dropped it will be  * after ack notifier java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        vcpu_bitmap trigger_mode  |
   }
 (,
         
  } else {
 (>)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
  }
  breaki>[];
 }
}

static int ioapic_service(struct    * immediately during eoi broadcast,   * lets a buggy guest make    * even if it does    * level-triggered interrupt.   * behavior if we detect java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 i>irq_eoi
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 int ret;

 if (  * =>>.vioapic
entry-trig_mode  &
     entry-,)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
 -

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 irqe ;
irqe =kvm_lapic_irq_dest_mode>.)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 static struct *(struct dev
 irqe.  (,struct,);
 irqe.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 irqe

 .=)
  ioapic->irr_delivered  <>base_address ))java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55

   ,,voidjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  /*
 * pending_eoi cannot ever become negative (see
 * rtc_status_pending_eoi_check_valid) and the caller
 * ensures that it is only called if it is >= zero, namely
 * if rtc_irq_check_coalesced returns false).
 */

 
   &=0xff
            &ioapic->rtc_status(&>lock
  ioapic->case:
 
;

 if (ret && irqe.trig_mode == IOAPIC_LEVEL_TRIG)
  entry-java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24

l)
}

int  *(u64  ) =;
         :
{
 struct kvm_ioapic  4
   -.;
ret;

 BUG_ON( (KERN_WARNINGioapiclengthn, )java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56

 spin_lock(&ioapic->lock);
 irq_level     , ,   *)
      irq_source_id
 ret(,, , )

 spin_unlock(&ioapic-!(ioapic

 return
}ASSERT(  xf * alignment

static  )
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  i;
 struct kvm_ioapic *ioapic = container_of(work, struct kvm_ioapic,
  ;
 spin_lock(&ioapic->lock);
  (  ;i ;i+ java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
  :

  if (ent-> =*  ;
   continue ( ioapic %\nlen

  if (ioapic->irr
  oapic_service, , );
 }
 spin_unlock(&ioapic->lock);
}

#define IOAPIC_SUCCESSIVE_IRQ_MAX_COUNT   :
  kvm_ioapic_update_eoi_one *,
 
 ntjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
         pin)
{
 struct kvm_lapic *apic = vcpu->arch.apic;
 unionkvm_ioapic_redirect_entry =&>redirtbl]java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63

/*
 * We are dropping lock while calling ack notifiers because ack
 * notifier callbacks for assigned devices call into IOAPIC
 * recursively. Since remote_irr is cleared only after call
 * to notifiers if the same vector will be delivered while lock
 * is dropped it will be put into irr and will be delivered
 * after ack notifier returns.
 */

 spin_unlock( .write    = ioapic_mmio_write,
 kvm_notify_acked_irq};
 spin_lock(&ioapic->lock);int kvm_ioapic_init(struct kvm *kvm)

 if (trigger_mode != IOAPIC_LEVEL_TRIG ||
     kvm_lapic_get_reg(apic, java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 13
  return;

 ASSERT kvm-> kvm_ioapic_reset(ioapic);
 ent-> ioapic->kvm mutex_lock(& ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, ioapic->java.lang.StringIndexOutOfBoundsException: Range [0, 70) out of bounds for length 43
 if (!ent->fields return ret;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  if (ioapic->irq_eoi{
   /* struct kvm_ioapic *ioapic = kvm->arch.vioapic;
 * Real hardware does not deliver the interrupt
 * immediately during eoi broadcast, and this
 * lets a buggy guest make slow progress
 * even if it does not correctly handle a
 * level-triggered interrupt.  Emulate this
 * behavior if we detect an interrupt storm.
 */

   schedule_delayed_work(&ioapic->eoi_inject}
   ioapic-
   trace_kvm_ioapic_delayed_eoi_injvoid kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state)
  } else
    spin_lock(&ioapic->lock);
  }
 } else {
  ioapic->irq_eoi[pin] = 0;
 }
}

void 
{
 int i;
 struct kvm_ioapic *ioapic{

 spin_lock(&ioapic->lock);
 rtc_irq_eoi(ioapic, vcpu spin_lock(&ioapic->lock);
 for (i = ioapic->irr ioapic->irr_delivered = 0;
  union kvm_ioapic_redirect_entry * kvm_ioapic_inject_all(ioapic, state->irr);

   spin_unlock(&ioapic->lock);
   continue;
  kvm_ioapic_update_eoi_one(vcpu, ioapic, trigger_mode, i);
 }
 spin_unlock(&ioapic->lock);
}

static inline struct kvm_ioapic *to_ioapic(struct kvm_io_device *dev)
{
 return container_of(dev, struct kvm_ioapic, dev);
}

static inline int ioapic_in_range(struct kvm_ioapic *ioapic, gpa_t addr)
{
 return ((addr >= ioapic->base_address &&
   (addr < ioapic->base_address + IOAPIC_MEM_LENGTH)));
}

static int ioapic_mmio_read(struct kvm_vcpu *vcpu, struct kvm_io_device *this,
    gpa_t addr, int len, void *val)
{
 struct kvm_ioapic *ioapic = to_ioapic(this);
 u32 result;
 if (!ioapic_in_range(ioapic, addr))
  return -EOPNOTSUPP;

 ASSERT(!(addr & 0xf)); /* check alignment */

 addr &= 0xff;
 spin_lock(&ioapic->lock);
 switch (addr) {
 case IOAPIC_REG_SELECT:
  result = ioapic->ioregsel;
  break;

 case IOAPIC_REG_WINDOW:
  result = ioapic_read_indirect(ioapic);
  break;

 default:
  result = 0;
  break;
 }
 spin_unlock(&ioapic->lock);

 switch (len) {
 case 8:
  *(u64 *) val = result;
  break;
 case 1:
 case 2:
 case 4:
  memcpy(val, (char *)&result, len);
  break;
 default:
  printk(KERN_WARNING "ioapic: wrong length %d\n", len);
 }
 return 0;
}

static int ioapic_mmio_write(struct kvm_vcpu *vcpu, struct kvm_io_device *this,
     gpa_t addr, int len, const void *val)
{
 struct kvm_ioapic *ioapic = to_ioapic(this);
 u32 data;
 if (!ioapic_in_range(ioapic, addr))
  return -EOPNOTSUPP;

 ASSERT(!(addr & 0xf)); /* check alignment */

 switch (len) {
 case 8:
 case 4:
  data = *(u32 *) val;
  break;
 case 2:
  data = *(u16 *) val;
  break;
 case 1:
  data = *(u8  *) val;
  break;
 default:
  printk(KERN_WARNING "ioapic: Unsupported size %d\n", len);
  return 0;
 }

 addr &= 0xff;
 spin_lock(&ioapic->lock);
 switch (addr) {
 case IOAPIC_REG_SELECT:
  ioapic->ioregsel = data & 0xFF; /* 8-bit register */
  break;

 case IOAPIC_REG_WINDOW:
  ioapic_write_indirect(ioapic, data);
  break;

 default:
  break;
 }
 spin_unlock(&ioapic->lock);
 return 0;
}

static void kvm_ioapic_reset(struct kvm_ioapic *ioapic)
{
 int i;

 cancel_delayed_work_sync(&ioapic->eoi_inject);
 for (i = 0; i < IOAPIC_NUM_PINS; i++)
  ioapic->redirtbl[i].fields.mask = 1;
 ioapic->base_address = IOAPIC_DEFAULT_BASE_ADDRESS;
 ioapic->ioregsel = 0;
 ioapic->irr = 0;
 ioapic->irr_delivered = 0;
 ioapic->id = 0;
 memset(ioapic->irq_eoi, 0x00, sizeof(ioapic->irq_eoi));
 rtc_irq_eoi_tracking_reset(ioapic);
}

static const struct kvm_io_device_ops ioapic_mmio_ops = {
 .read     = ioapic_mmio_read,
 .write    = ioapic_mmio_write,
};

int kvm_ioapic_init(struct kvm *kvm)
{
 struct kvm_ioapic *ioapic;
 int ret;

 ioapic = kzalloc(sizeof(struct kvm_ioapic), GFP_KERNEL_ACCOUNT);
 if (!ioapic)
  return -ENOMEM;
 spin_lock_init(&ioapic->lock);
 INIT_DELAYED_WORK(&ioapic->eoi_inject, kvm_ioapic_eoi_inject_work);
 INIT_HLIST_HEAD(&ioapic->mask_notifier_list);
 kvm->arch.vioapic = ioapic;
 kvm_ioapic_reset(ioapic);
 kvm_iodevice_init(&ioapic->dev, &ioapic_mmio_ops);
 ioapic->kvm = kvm;
 mutex_lock(&kvm->slots_lock);
 ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, ioapic->base_address,
          IOAPIC_MEM_LENGTH, &ioapic->dev);
 mutex_unlock(&kvm->slots_lock);
 if (ret < 0) {
  kvm->arch.vioapic = NULL;
  kfree(ioapic);
 }

 return ret;
}

void kvm_ioapic_destroy(struct kvm *kvm)
{
 struct kvm_ioapic *ioapic = kvm->arch.vioapic;

 if (!ioapic)
  return;

 cancel_delayed_work_sync(&ioapic->eoi_inject);
 mutex_lock(&kvm->slots_lock);
 kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, &ioapic->dev);
 mutex_unlock(&kvm->slots_lock);
 kvm->arch.vioapic = NULL;
 kfree(ioapic);
}

void kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state)
{
 struct kvm_ioapic *ioapic = kvm->arch.vioapic;

 spin_lock(&ioapic->lock  *    MandrakeSoft *     *    7500 *    http://www.linux-mandrake.com/
 memcpy(state *  License as published *  version 2 of  *  This library is WARRANTY; without even theR PURPOSE.  See the *  Lesser  * *  You should have *  License along with *  Foundation, *  Yunhong *   *  Basedpr_fmt()KBUILD_MODNAME"java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  )
(ioapic-)
}

void kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state)
{
 struct kvm_ioapic *ioapic = kvm->arch.vioapic        trigger_mode

 spin_lock(&ioapic->lock);
 memcpy(ioapic, state, sizeof(
 ioapic-irr = 0;
 java.lang.StringIndexOutOfBoundsException: Range [22, 8) out of bounds for length 27
vm;
 kvm_ioapic_inject_all(oapic state-irrjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 spin_unlock  result (ioapic-id& xf <24)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
}

Messung V0.5
C=96 H=92 G=93

¤ Dauer der Verarbeitung: 0.14 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.