iPXE
Macros | Functions | Variables
xengrant.h File Reference

Xen grant tables. More...

#include <stdint.h>
#include <stdlib.h>
#include <ipxe/io.h>
#include <ipxe/xen.h>
#include <xen/grant_table.h>

Go to the source code of this file.

Macros

#define XENGRANT_FAIL_RATE   0
 Induced failure rate (for testing) More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static __attribute__ ((always_inline)) int xengrant_query_size(struct xen_hypervisor *xen
 Query grant table size. More...
 
 return (container_of(&v1->flags, struct grant_entry_header, flags))
 
static void xengrant_zero (struct xen_hypervisor *xen, struct grant_entry_header *hdr)
 Zero grant table entry. More...
 
 assert ((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
 
 writew (0, &hdr->flags)
 
 writew (DOMID_SELF, &hdr->domid)
 
 if ((XENGRANT_FAIL_RATE > 0) &&(random() % XENGRANT_FAIL_RATE)==0)
 
 if (sizeof(physaddr_t)==sizeof(uint64_t))
 
 wmb ()
 
 writew ((GTF_permit_access|subflags), &hdr->flags)
 
int xengrant_init (struct xen_hypervisor *xen)
 Initialise grant table. More...
 
int xengrant_alloc (struct xen_hypervisor *xen, grant_ref_t *refs, unsigned int count)
 Allocate grant references. More...
 
void xengrant_free (struct xen_hypervisor *xen, grant_ref_t *refs, unsigned int count)
 Free grant references. More...
 

Variables

static struct gnttab_query_sizesize
 
static struct gnttab_set_version * version
 
static grant_ref_t ref
 
 v1 = &xen->grant.table[ ref << xen->grant.shift ]
 
static grant_ref_t domid_t domid
 
static grant_ref_t domid_t unsigned int subflags
 
static grant_ref_t domid_t unsigned int physaddr_t addr
 
union grant_entry_v2 * v2 = xengrant_v2 ( hdr )
 
unsigned long frame = ( addr / PAGE_SIZE )
 
 else
 
 return
 

Detailed Description

Xen grant tables.

Definition in file xengrant.h.

Macro Definition Documentation

◆ XENGRANT_FAIL_RATE

#define XENGRANT_FAIL_RATE   0

Induced failure rate (for testing)

Definition at line 19 of file xengrant.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ __attribute__()

static __attribute__ ( (always_inline)  )
inlinestatic

Query grant table size.

Permit access to a page.

Invalidate access to a page.

Get version 2 grant table entry.

Get version 1 grant table entry.

Get grant table entry header.

Get number of grant table entries.

Get grant table version.

Set grant table version.

Parameters
xenXen hypervisor
sizeTable size
Return values
xenrcXen status code
Parameters
xenXen hypervisor
versionVersion
Return values
xenrcXen status code
Parameters
xenXen hypervisor
Return values
entriesNumber of grant table entries
Parameters
xenXen hypervisor
refGrant reference
Return values
hdrGrant table entry header
Parameters
hdrGrant table entry header
Return values
v1Version 1 grant table entry
Parameters
hdrGrant table entry header
Return values
v2Version 2 grant table entry
Parameters
xenXen hypervisor
refGrant reference
xenXen hypervisor
refGrant reference
domidDomain ID
subflagsAdditional flags
addrPhysical address within page
Return values
rcReturn status code

Definition at line 75 of file xengrant.h.

76  {
77 
78  return ( ( xen->grant.len / sizeof ( xen->grant.table[0] ) )
79  >> xen->grant.shift );
80 }

References xen_hypervisor::grant, xen_grant::len, xen_grant::shift, xen_grant::table, and xen_device::xen.

◆ return()

return ( container_of &->,,  flags)

◆ xengrant_zero()

static void xengrant_zero ( struct xen_hypervisor xen,
struct grant_entry_header *  hdr 
)
inlinestatic

Zero grant table entry.

Parameters
xenXen hypervisor
hdrGrant table entry header

Definition at line 127 of file xengrant.h.

128  {
129  uint32_t *dword = ( ( uint32_t * ) hdr );
130  unsigned int i = ( ( sizeof ( xen->grant.table[0] ) / sizeof ( *dword ))
131  << xen->grant.shift );
132 
133  while ( i-- )
134  writel ( 0, dword++ );
135 }
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
struct grant_entry_v1 * table
Grant table entries.
Definition: xen.h:31
unsigned int uint32_t
Definition: stdint.h:12
unsigned int shift
Entry size shift (for later version tables)
Definition: xen.h:35
struct xen_grant grant
Grant table.
Definition: xen.h:57
unsigned long int dword
Definition: smc9000.h:40

References xen_hypervisor::grant, hdr, xen_grant::shift, xen_grant::table, and writel().

Referenced by xengrant_alloc(), and xengrant_free().

◆ assert()

assert ( (readw(&hdr->flags) &(GTF_reading|GTF_writing))  = =0)

Referenced by __attribute__(), _print_label(), a3c90x_internal_ReadEeprom(), acm_transmit(), adaptive_proportion_test_init(), aes_decrypt(), aes_encrypt(), alloc_form(), alloc_iob_raw(), alloc_memblock(), ansicol_set(), ansicol_set_pair(), aoecmd_ata_cmd(), aoecmd_cfg_cmd(), aoecmd_free(), aoecmd_tx(), arbel_alloc_icm(), arbel_close(), arbel_cmd(), arbel_complete(), arbel_map_vpm(), arbel_post_send(), arbel_start_firmware(), asn1_enter_partial(), asn1_okx(), asn1_parse_cbc(), atadev_read_capacity(), ath5k_handle_rx(), atl_rx_ring_fill(), axge_in_complete(), bigint_mod_invert_raw(), bigint_mod_multiply_raw(), bigint_reduce_raw(), bios_ansi_seq(), bios_handle_ed(), blktrans_xferbuf_read(), blktrans_xferbuf_write(), bnxt_rx_process(), bzimage_exec(), cachedhcp_record(), cachedhcp_recycle(), cbc_decrypt(), cbc_encrypt(), cbc_setiv(), cbc_xor(), chap_init(), chap_respond(), chap_update(), check_blocks(), cipher_cost(), cms_parse_enveloped(), cms_test_exec(), cms_verify_padding(), cms_verify_signer(), com32_exec_loop(), comboot_exec_loop(), concat_args(), deflate_accumulate(), deflate_bin(), deflate_consume(), deflate_inflate(), deflate_init(), delete_character(), des_decrypt(), des_encrypt(), des_setkey(), dhcp_create_request(), dhcpv6_rx(), dhcpv6_tx(), dma_op_free(), dma_op_ufree(), dma_op_unmap(), DMAAPI_INLINE(), dns_xfer_deliver(), drbg_generate(), drbg_instantiate(), drbg_reseed(), drbg_uninstantiate(), eap_rx_md5(), eap_rx_mschapv2_success(), eap_tx_nak(), eapol_eap_rx(), ecam_read(), ecam_write(), ecb_decrypt(), ecb_encrypt(), ecm_probe(), edit_setting(), eepro_transmit(), efab_fill_rx_queue(), efab_receive(), efab_transmit(), efab_transmit_done(), efi_bofm_start(), efi_bofm_stop(), efi_driver_stop(), efi_file_install(), efi_file_path_claim(), efi_file_path_install(), efi_file_read(), efi_handle_ed(), efi_image_exec(), efi_local_open_path(), efi_local_step(), efi_netdev_path(), efi_pxe_udp_deliver(), efi_snp_add_claim(), efi_snp_set_mode(), efi_urealloc(), efi_usb_close(), efi_usb_free_all(), efi_usb_path(), efi_usb_probe(), efi_usb_remove(), efi_usb_sync_transfer(), efi_vlan_find(), efidev_free(), efifb_draw(), efipci_dma_map(), efipci_stop(), efirng_get_noise(), efx_hunt_alloc_special_buffer(), efx_hunt_receive(), efx_hunt_rxq_fill(), efx_hunt_transmit(), efx_hunt_transmit_done(), ehci_bus_close(), ehci_bus_open(), ehci_bus_poll(), ehci_dequeue(), ehci_device_address(), ehci_endpoint_capabilities(), ehci_endpoint_message(), ehci_endpoint_reset(), ehci_enqueue(), ehci_remove(), ehci_ring_fill(), ehci_ring_free(), ena_poll_rx(), ena_poll_tx(), ena_refill_rx(), ena_transmit(), entropy_enable(), entropy_enable_and_test(), eoib_transmit(), exanic_expired(), exanic_i2c_read_bit(), exanic_i2c_write_bit(), exanic_probe_port(), expand_tokens(), falcon_alloc_special_buffer(), falcon_mdio_read(), falcon_mdio_write(), falcon_spi_rw(), fbcon_handle_ed(), fbcon_init(), fbcon_scroll(), fc_els_free(), fc_els_step(), fc_peer_close(), fc_peer_decrement(), fc_peer_examine(), fc_peer_login(), fc_ulp_attach(), fc_ulp_close(), fc_ulp_login(), fc_xchg_free(), fcoe_expired(), fcpcmd_recv_rddata(), fcpcmd_send_cmnd(), fcpcmd_send_wrdata(), fcpdev_identify_device(), fcpdev_scsi_command(), fdt_traverse(), fetch_setting_alloc(), fetchf_setting(), fetchf_setting_copy(), fetchn_setting(), find_smbios_structure(), flexboot_nodnic_complete(), flexboot_nodnic_post_send(), format_busdevfn_setting(), free_iob(), free_memblock(), free_netdev(), free_tls(), free_tls_session(), free_usb(), free_usb_bus(), free_usb_hub(), gcm_multiply_x_8(), gcm_setiv(), gdbserial_recv(), gdbudp_ensure_netdev_open(), generic_settings_clear(), get_entropy_input_tmp(), golan_complete(), golan_provide_pages(), guestinfo_fetch_type(), guestrpc_command(), gve_alloc_qpl(), gve_alloc_queue(), gve_create_queue(), gve_poll_rx(), gve_probe(), gve_transmit(), gzip_extract(), hash_df(), hermon_close(), hermon_cmd(), hermon_complete(), hermon_map_icm(), hermon_map_vpm(), hermon_mod_stat_cfg(), hermon_post_send(), hermon_set_port_type(), hermon_start_firmware(), hide_umalloc(), history_append(), history_cleanup(), history_free(), hmac_drbg_generate(), hmac_drbg_instantiate(), hmac_drbg_reseed(), hmac_drbg_update(), hmac_drbg_update_key(), hmac_drbg_update_value(), http_block_read(), http_conn_close(), http_connect(), http_format_basic_auth(), http_format_digest_auth(), http_format_ntlm_auth(), http_init_transfer_chunked(), http_open_uri(), http_parse_headers(), http_rx_chunk_data(), http_transfer_complete(), http_tx_request(), hub_remove(), hunt_mcdi_copyin(), hv_post_message(), hv_wait_for_message(), hvm_ioremap(), ib_destroy_cq(), ib_destroy_qp(), ib_mcast_attach(), ib_mcast_detach(), ib_mcast_join(), ib_mcast_leave(), ib_mi_send(), ib_open(), ib_pull(), ibft_fill_target_chap(), ibft_fill_target_reverse_chap(), ibft_install(), icert_cert(), icert_certs(), icert_encode(), icm_align(), icplus_read_eeprom(), icplus_refill_rx(), if(), image_asn1(), image_exec(), image_replace(), imux_tx(), imux_tx_tcp(), init_i2c_bit_basher(), init_spi_bit_basher(), initrd_swap(), int13_device_path_info(), int13_guess_geometry(), int22(), intel_read_eeprom(), intel_refill_rx(), intelvf_mbox_msg(), intelxl_admin_command(), intelxl_refill_rx(), iob_map_rx(), iob_pad(), iob_pull(), iob_split(), ioremap_pages(), iounmap_pages(), ipair_expired(), ipair_window_changed(), ipv6_add_miniroute(), iscsi_build_login_request_strings(), iscsi_fetch_settings(), iscsi_open_connection(), iscsi_rx_buffered_data(), iscsi_rx_data_in(), iscsi_scsi_done(), iscsi_socket_deliver(), iscsi_start_command(), iscsi_start_login(), iscsi_start_tx(), iscsi_tx_data_out(), iscsi_tx_step(), jump_scroll(), jump_scroll_key(), jump_scroll_move(), kill_eol(), kill_sol(), kill_word(), last_opened_ibdev(), last_opened_netdev(), layout_form(), linda_complete_recv(), linda_complete_send(), linda_ib_epb_mod_reg(), linda_ib_epb_ram_xfer(), linda_post_recv(), linda_post_send(), line_buffer(), lldp_probe(), longjmp_okx(), main_loop(), md4_digest(), md4_final(), md5_digest(), md5_final(), memcpy_test_speed(), menu_loop(), mnpnet_event(), mschapv2_challenge_response(), myson_refill_rx(), natsemi_refill_rx(), nbi_process_segments(), ncm_probe(), ndp_register_settings(), neighbour_free(), net80211_change_channel(), net80211_mgmt_dequeue(), net80211_prepare_assoc(), net80211_prepare_probe(), net80211_probe_start(), net80211_set_rate_idx(), netdev_fetch_bustype(), netdev_priv_offset(), netdev_tx_flush(), netfront_create_ring(), netfront_open(), netfront_pull(), netfront_push(), netvsc_create_ring(), netvsc_destroy_ring(), netvsc_transmit(), nii_get_init_info(), numerate_int_setting(), nvs_read(), nvs_write(), ocsp_check(), ocsp_validate(), parse_fc_port(), parse_fc_port_id(), parse_gdb_transport(), parse_integer(), parse_netdev(), parse_netdev_configurator(), parse_setting(), parse_settings(), parse_string(), parse_uuid(), pci_msix_map(), pci_vpd_resize(), peerblk_decrypt(), peerblk_dequeue(), peerblk_enqueue(), peerblk_expired(), peerblk_parse_block(), peerblk_parse_header(), peerblk_reset(), peerdisc_destroy(), peerdisc_open(), peerdist_discovery_reply_values(), peerdist_info(), peerdist_info_block(), peerdist_info_hash_ntoa(), peerdist_info_segment(), peerdist_info_segment_hash(), peerdist_info_v1(), peerdist_info_v1_block(), peerdist_info_v1_block_offset(), peerdist_info_v1_segment(), peerdist_info_v2(), peerdist_info_v2_block(), peerdist_info_v2_segment(), peermux_block_deliver(), pem_asn1(), pem_marker(), phantom_clp_cmd(), phantom_crb_access_128m(), phantom_crb_access_2m(), phantom_crb_access_32m(), phantom_dmesg(), phantom_fetch_setting(), phantom_poll(), phantom_probe(), phantom_refill_rx_ring(), phantom_store_setting(), phantom_transmit(), ping_rx(), pit8254_speaker_delay(), pixbuf_okx(), png_interlace(), png_pixels(), png_pixels_pass(), png_unfilter(), png_unfilter_pass(), pnm_type(), pool_add(), pool_expired(), profile_update(), pxe_fake_cached_info(), pxe_menu_boot(), pxe_netdev_close(), pxe_netdev_open(), pxe_udp_deliver(), pxenv_udp_read(), pxenv_undi_get_information(), qib7322_ahb_mod_reg(), qib7322_complete_recv(), qib7322_complete_send(), qib7322_post_recv(), qib7322_post_send(), qib7322_probe(), rdc_refill_rx(), read_smbios_string(), read_smbios_structure(), read_user(), readline_history(), realloc(), realtek_refill_rx(), register_settings(), register_usb(), register_usb_bus(), reparse_options(), repetition_count_test_init(), rfc_tcpip_chksum(), rndis_tx_defer(), rsa_encode_digest(), rtc_unhook_isr(), run_tests(), sandev_command(), sandev_command_read_capacity(), sandev_command_rw(), sandev_free(), sandev_reopen(), save_setting(), sdi_exec(), sha1_digest(), sha1_final(), sha256_digest(), sha256_final(), sha512_digest(), sha512_final(), show_menu(), shuffle(), skge_up(), skge_xmit_frame(), sky2_status_intr(), sky2_tx_complete(), slam_parse_multicast_address(), slam_pull_header(), slam_put_value(), smbios_version(), spi_bit_rw(), srp_open(), srpcmd_free(), startup_test_init(), storef_setting(), storen_setting(), tcp_close(), tcp_expired(), tcp_rx_opts(), tcp_rx_seq(), tcp_wait_expired(), tcp_xmit_sack(), tcpip_random_okx(), test_ok(), tg3_rx_complete(), threewire_read(), threewire_write(), timer_expired(), tls_cipherstream_deliver(), tls_generate_keys(), tls_new_ciphertext(), tls_new_record(), tls_newdata_process_data(), tls_newdata_process_header(), tls_restart(), tls_send_plaintext(), tls_set_cipher(), tls_tx_step(), tls_validator_done(), tls_verify_dh_params(), txnic_complete_sqe(), txnic_lmac_probe(), txnic_lmac_probe_all(), txnic_lmac_remove(), txnic_lmac_remove_all(), txnic_refill_rq(), ucode_exec(), ucode_status(), ucode_update_all(), uhci_bus_close(), uhci_bus_open(), uhci_dequeue(), uhci_device_address(), uhci_endpoint_message(), uhci_endpoint_poll(), uhci_endpoint_stream(), uhci_enqueue(), uhci_remove(), uhci_restart(), uhci_ring_fill(), uhci_ring_free(), undinet_call(), undinet_hook_isr(), undinet_unhook_isr(), unregister_sandev(), unregister_usb(), unregister_usb_bus(), usb_attached(), usb_complete_err(), usb_control(), usb_deconfigure(), usb_describe(), usb_endpoint_close(), usb_endpoint_reset(), usb_flush(), usb_free_address(), usb_hotplug(), usb_message(), usb_prefill(), usb_probe_all(), usb_refill_limit(), usb_remove_all(), usbblk_in_complete(), usbblk_in_data(), usbblk_in_refill(), usbblk_in_status(), usbblk_open(), usbblk_out_command(), usbblk_out_complete(), usbblk_out_data(), usbblk_out_refill(), usbblk_start(), usbio_close(), usbio_endpoint_message(), usbio_interfaces(), usbio_interrupt_callback(), usbio_interrupt_poll(), usbio_open(), usbkbd_consume(), usbkbd_fill(), utf8_accumulate(), validator_append(), validator_start_ocsp(), validator_step(), validator_xfer_close(), vmbus_open(), vmbus_poll(), vmbus_probe(), vmbus_remove_channels(), vmbus_send(), vmbus_send_cancellation(), vmbus_send_completion(), vmbus_send_control(), vmbus_send_data(), vmbus_xfer_page_iobufs(), vmxnet3_refill_rx(), vmxnet3_transmit(), vpm_ioread16(), vpm_ioread32(), vpm_ioread8(), vpm_iowrite16(), vpm_iowrite32(), vpm_iowrite8(), vxge_hw_device_terminate(), write_cmd(), x25519_invert(), x509_check_signature(), x509_found(), x509_free_chain(), x509_set_valid(), x509_test_exec(), xcm_free(), xengrant_alloc(), xengrant_free(), xenstore_request(), xhci_address_device_input(), xhci_bus_close(), xhci_command_free(), xhci_complete(), xhci_dcbaa_free(), xhci_dequeue(), xhci_device_open(), xhci_endpoint_message(), xhci_endpoint_open(), xhci_enqueue(), xhci_enqueue_multi(), xhci_fail(), xhci_init(), xhci_port_status(), xhci_ring_alloc(), xhci_ring_free(), xhci_ring_remaining(), xhci_scratchpad_alloc(), xhci_scratchpad_free(), xhci_transfer(), and xsigo_free().

◆ writew() [1/3]

writew ( ,
&hdr->  flags 
)

◆ writew() [2/3]

writew ( DOMID_SELF  ,
&hdr->  domid 
)

◆ if() [1/2]

if ( (XENGRANT_FAIL_RATE > 0) &&(random() % XENGRANT_FAIL_RATE = = 0)

Definition at line 182 of file xengrant.h.

183  {
184  return -EAGAIN;
185  }
#define EAGAIN
Resource temporarily unavailable.
Definition: errno.h:318

References EAGAIN.

◆ if() [2/2]

if ( sizeof(physaddr_t = = sizeof ( uint64_t ))

Definition at line 193 of file xengrant.h.

193  {
194 
195  /* 64-bit system */
196  if ( xen->grant.shift ) {
197  /* Version 2 table: no possible failure */
198  writeq ( frame, &v2->full_page.frame );
199  } else {
200  /* Version 1 table: may fail if address above 16TB */
201  if ( frame > 0xffffffffUL )
202  return -ERANGE;
203  writel ( frame, &v1->frame );
204  }
205 
206  } else {
v1
Definition: xengrant.h:93
unsigned long frame
Definition: xengrant.h:179
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define ERANGE
Result too large.
Definition: errno.h:639
union grant_entry_v2 * v2
Definition: xengrant.h:178
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References ERANGE, frame, xen_hypervisor::grant, xen_grant::shift, v1, v2, writel(), and writeq().

◆ wmb()

wmb ( )

Referenced by __vxge_hw_kdfc_swapper_set(), __vxge_hw_legacy_swapper_set(), __vxge_hw_non_offload_db_post(), __vxge_hw_pio_mem_write64(), __vxge_hw_read_rts_ds(), __vxge_hw_vpath_kdfc_configure(), __vxge_hw_vpath_pci_read(), __vxge_hw_vpath_swapper_set(), amd8111e_init_rx_ring(), amd8111e_poll(), amd8111e_transmit(), atl1e_read_phy_reg(), atl1e_reset_hw(), atl1e_tx_queue(), atl1e_write_phy_reg(), atl_rx_ring_fill(), atl_transmit(), b44_transmit(), bnx2_poll(), bnx2_transmit(), clear_b0_fpga_memories(), ehci_async_schedule(), ehci_endpoint_reset(), ehci_enqueue(), ehci_periodic_schedule(), ena_admin(), ena_destroy_admin(), ena_destroy_async(), ena_refill_rx(), ena_transmit(), exanic_close(), exanic_open(), exanic_transmit(), falcon_read(), falcon_write(), falcon_write_sram(), flexboot_nodnic_arm_cq(), forcedeth_transmit(), golan_cmd_init(), golan_eq_update_ci(), golan_post_recv(), golan_post_send(), gve_admin(), gve_reset(), gve_transmit(), hunt_mcdi_copyin(), icplus_refill_rx(), icplus_transmit(), intel_refill_rx(), intel_transmit(), intelxl_admin_command(), intelxl_refill_admin(), intelxl_refill_rx(), intelxl_transmit(), is_command_finished(), jme_disable_rx_engine(), jme_disable_tx_engine(), jme_enable_rx_engine(), jme_enable_tx_engine(), jme_fill_tx_desc(), jme_mdio_write(), jme_set_clean_rxdesc(), jme_setup_wakeup_frame(), myri10ge_command(), myri10ge_interrupt_handler(), myri10ge_net_poll(), myri10ge_net_transmit(), myri10ge_post_receive(), myson_refill_rx(), myson_transmit(), natsemi_refill_rx(), natsemi_transmit(), nv_alloc_rx(), pci_push(), pcnet32_refill_rx_ring(), pcnet32_setup_init_block(), pcnet32_transmit(), phantom_poll(), phantom_post_cds(), phantom_post_rds(), rdc_refill_rx(), rdc_transmit(), realtek_refill_rx(), realtek_transmit(), rhine_refill_rx(), rhine_transmit(), send_command(), shomron_tx_uar_send_db(), sis190_give_to_asic(), sis190_make_unusable_by_asic(), sis190_transmit(), skge_poll(), skge_rx_reuse(), skge_rx_setup(), skge_up(), skge_xmit_frame(), sky2_put_idx(), sky2_rx_stop(), txnic_refill_rq(), txnic_send(), uhci_async_schedule(), uhci_describe(), uhci_endpoint_poll(), uhci_enqueue(), uhci_periodic_schedule(), uhci_restart(), velocity_refill_rx(), velocity_transmit(), vmbus_send(), vmxnet3_refill_rx(), vmxnet3_transmit(), vring_add_buf(), vring_detach(), vring_get_buf(), vring_kick(), vring_more_used(), vxge_hw_device_hw_info_get(), vxge_hw_set_fw_api(), vxge_hw_vpath_doorbell_rx(), vxge_open(), xenstore_recv(), xenstore_send(), xhci_doorbell(), and xhci_enqueue().

◆ writew() [3/3]

writew ( (GTF_permit_access|subflags ,
&hdr->  flags 
)

◆ xengrant_init()

int xengrant_init ( struct xen_hypervisor xen)

Initialise grant table.

Parameters
xenXen hypervisor
Return values
rcReturn status code

Definition at line 70 of file xengrant.c.

70  {
71  struct gnttab_query_size size;
72  struct gnttab_set_version set_version;
73  struct gnttab_get_version get_version;
74  struct grant_entry_v1 *v1;
75  union grant_entry_v2 *v2;
76  unsigned int version;
77  int xenrc;
78  int rc;
79 
80  /* Get grant table size */
81  size.dom = DOMID_SELF;
82  if ( ( xenrc = xengrant_query_size ( xen, &size ) ) != 0 ) {
83  rc = -EXEN ( xenrc );
84  DBGC ( xen, "XENGRANT could not get table size: %s\n",
85  strerror ( rc ) );
86  return rc;
87  }
88  xen->grant.len = ( size.nr_frames * PAGE_SIZE );
89 
90  /* Set grant table version, if applicable */
91  set_version.version = XENGRANT_TRY_VERSION;
92  if ( ( xenrc = xengrant_set_version ( xen, &set_version ) ) != 0 ) {
93  rc = -EXEN ( xenrc );
94  DBGC ( xen, "XENGRANT could not set version %d: %s\n",
96  /* Continue; use whatever version is current */
97  }
98 
99  /* Get grant table version */
100  get_version.dom = DOMID_SELF;
101  get_version.pad = 0;
102  if ( ( xenrc = xengrant_get_version ( xen, &get_version ) ) == 0 ) {
103  version = get_version.version;
104  switch ( version ) {
105 
106  case 0:
107  /* Version not yet specified: will be version 1 */
108  version = 1;
109  break;
110 
111  case 1 :
112  /* Version 1 table: nothing special to do */
113  break;
114 
115  case 2:
116  /* Version 2 table: configure shift appropriately */
117  xen->grant.shift = ( fls ( sizeof ( *v2 ) /
118  sizeof ( *v1 ) ) - 1 );
119  break;
120 
121  default:
122  /* Unsupported version */
123  DBGC ( xen, "XENGRANT detected unsupported version "
124  "%d\n", version );
125  return -ENOTSUP;
126 
127  }
128  } else {
129  rc = -EXEN ( xenrc );
130  DBGC ( xen, "XENGRANT could not get version (assuming v1): "
131  "%s\n", strerror ( rc ) );
132  version = 1;
133  }
134 
135  DBGC ( xen, "XENGRANT using v%d table with %d entries\n",
136  version, xengrant_entries ( xen ) );
137  return 0;
138 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
v1
Definition: xengrant.h:93
#define PAGE_SIZE
Page size.
Definition: io.h:27
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
#define EXEN(xenrc)
Convert a Xen status code to an iPXE status code.
Definition: xen.h:87
u32 version
Driver version.
Definition: ath9k_hw.c:1983
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
Definition: grant_table.h:117
union grant_entry_v2 * v2
Definition: xengrant.h:178
#define XENGRANT_TRY_VERSION
Grant table version to try setting.
Definition: xengrant.c:62
unsigned int shift
Entry size shift (for later version tables)
Definition: xen.h:35
struct xen_grant grant
Grant table.
Definition: xen.h:57
#define DOMID_SELF
Definition: xen.h:567
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
size_t len
Total grant table length.
Definition: xen.h:33
#define fls(x)
Find last (i.e.
Definition: strings.h:166

References DBGC, DOMID_SELF, ENOTSUP, EXEN, fls, xen_hypervisor::grant, xen_grant::len, PAGE_SIZE, rc, xen_grant::shift, size, strerror(), v1, v2, version, and XENGRANT_TRY_VERSION.

Referenced by hvm_map_grant().

◆ xengrant_alloc()

int xengrant_alloc ( struct xen_hypervisor xen,
grant_ref_t refs,
unsigned int  count 
)

Allocate grant references.

Parameters
xenXen hypervisor
refsGrant references to fill in
countNumber of references
Return values
rcReturn status code

Definition at line 148 of file xengrant.c.

149  {
150  struct grant_entry_header *hdr;
151  unsigned int entries = xengrant_entries ( xen );
152  unsigned int mask = ( entries - 1 );
153  unsigned int check = 0;
154  unsigned int avail;
155  unsigned int ref;
156 
157  /* Fail unless we have enough references available */
158  avail = ( entries - xen->grant.used - GNTTAB_NR_RESERVED_ENTRIES );
159  if ( avail < count ) {
160  DBGC ( xen, "XENGRANT cannot allocate %d references (only %d "
161  "of %d available)\n", count, avail, entries );
162  return -ENOBUFS;
163  }
164  DBGC ( xen, "XENGRANT allocating %d references (from %d of %d "
165  "available)\n", count, avail, entries );
166 
167  /* Update number of references used */
168  xen->grant.used += count;
169 
170  /* Find unused references */
171  for ( ref = xen->grant.ref ; count ; ref = ( ( ref + 1 ) & mask ) ) {
172 
173  /* Sanity check */
174  assert ( check++ < entries );
175 
176  /* Skip reserved references */
178  continue;
179 
180  /* Skip in-use references */
181  hdr = xengrant_header ( xen, ref );
182  if ( readw ( &hdr->flags ) & GTF_type_mask )
183  continue;
184  if ( readw ( &hdr->domid ) == DOMID_SELF )
185  continue;
186 
187  /* Zero reference */
188  xengrant_zero ( xen, hdr );
189 
190  /* Mark reference as in-use. We leave the flags as
191  * empty (to avoid creating a valid grant table entry)
192  * and set the domid to DOMID_SELF.
193  */
194  writew ( DOMID_SELF, &hdr->domid );
195  DBGC2 ( xen, "XENGRANT allocated ref %d\n", ref );
196 
197  /* Record reference */
198  refs[--count] = ref;
199  }
200 
201  /* Update cursor */
202  xen->grant.ref = ref;
203 
204  return 0;
205 }
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
uint16_t readw(volatile uint16_t *io_addr)
Read 16-bit word from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define GNTTAB_NR_RESERVED_ENTRIES
Definition: grant_table.h:135
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
uint16_t count
Number of entries.
Definition: ena.h:22
#define GTF_type_mask
Definition: grant_table.h:152
static const char grant_ref_t unsigned int struct io_buffer grant_ref_t * refs
Definition: netfront.h:93
unsigned int ref
Most recently used grant reference.
Definition: xen.h:39
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define DBGC2(...)
Definition: compiler.h:522
struct xen_grant grant
Grant table.
Definition: xen.h:57
#define writew
Definition: w89c840.c:159
#define DOMID_SELF
Definition: xen.h:567
static const char grant_ref_t ref
Definition: netfront.h:91
static void xengrant_zero(struct xen_hypervisor *xen, struct grant_entry_header *hdr)
Zero grant table entry.
Definition: xengrant.h:127
unsigned int used
Number of grant table entries in use.
Definition: xen.h:37

References assert(), count, DBGC, DBGC2, DOMID_SELF, ENOBUFS, GNTTAB_NR_RESERVED_ENTRIES, xen_hypervisor::grant, GTF_type_mask, hdr, readw(), xen_grant::ref, ref, refs, xen_grant::used, writew, and xengrant_zero().

Referenced by netfront_probe().

◆ xengrant_free()

void xengrant_free ( struct xen_hypervisor xen,
grant_ref_t refs,
unsigned int  count 
)

Free grant references.

Parameters
xenXen hypervisor
refsGrant references
countNumber of references

Definition at line 214 of file xengrant.c.

215  {
216  struct grant_entry_header *hdr;
217  unsigned int ref;
218  unsigned int i;
219 
220  /* Free references */
221  for ( i = 0 ; i < count ; i++ ) {
222 
223  /* Sanity check */
224  ref = refs[i];
225  assert ( ref < xengrant_entries ( xen ) );
226 
227  /* Zero reference */
228  hdr = xengrant_header ( xen, ref );
229  xengrant_zero ( xen, hdr );
230  DBGC2 ( xen, "XENGRANT freed ref %d\n", ref );
231  }
232 }
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
uint16_t count
Number of entries.
Definition: ena.h:22
static const char grant_ref_t unsigned int struct io_buffer grant_ref_t * refs
Definition: netfront.h:93
#define DBGC2(...)
Definition: compiler.h:522
static const char grant_ref_t ref
Definition: netfront.h:91
static void xengrant_zero(struct xen_hypervisor *xen, struct grant_entry_header *hdr)
Zero grant table entry.
Definition: xengrant.h:127

References assert(), count, DBGC2, hdr, ref, refs, and xengrant_zero().

Referenced by netfront_probe(), and netfront_remove().

Variable Documentation

◆ size

struct gnttab_query_size* size
Initial value:
{
return xen_hypercall_3 ( xen, __HYPERVISOR_grant_table_op,
virt_to_phys ( size ), 1 )
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:361
#define __HYPERVISOR_grant_table_op
Definition: xen.h:96
#define GNTTABOP_query_size
Definition: grant_table.h:295
static struct gnttab_query_size * size
Definition: xengrant.h:30

Definition at line 30 of file xengrant.h.

◆ version

struct gnttab_get_version* version
Initial value:
{
return xen_hypercall_3 ( xen, __HYPERVISOR_grant_table_op,
GNTTABOP_set_version,
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:361
static struct gnttab_set_version * version
Definition: xengrant.h:46
#define __HYPERVISOR_grant_table_op
Definition: xen.h:96

Definition at line 46 of file xengrant.h.

◆ ref

Initial value:

Definition at line 90 of file xengrant.h.

◆ v1

struct grant_entry_v1 * v1 = &xen->grant.table[ ref << xen->grant.shift ]

Definition at line 93 of file xengrant.h.

Referenced by if(), and xengrant_init().

◆ domid

Definition at line 173 of file xengrant.h.

◆ subflags

grant_ref_t domid_t unsigned int subflags

Definition at line 173 of file xengrant.h.

◆ addr

grant_ref_t domid_t unsigned int physaddr_t addr
Initial value:
{
struct grant_entry_header *hdr = xengrant_header ( xen, ref )
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
static grant_ref_t ref
Definition: xengrant.h:90

Definition at line 175 of file xengrant.h.

◆ v2

union grant_entry_v2* v2 = xengrant_v2 ( hdr )

Definition at line 178 of file xengrant.h.

Referenced by if(), and xengrant_init().

◆ frame

unsigned long frame = ( addr / PAGE_SIZE )

◆ else

else
Initial value:
{
if ( xen->grant.shift ) {
writel ( frame, &v2->full_page.frame );
} else {
writel ( frame, &v1->frame );
}
}
writew ( domid, &hdr->domid )
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
v1
Definition: xengrant.h:93
unsigned long frame
Definition: xengrant.h:179
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static grant_ref_t domid_t domid
Definition: xengrant.h:173
union grant_entry_v2 * v2
Definition: xengrant.h:178
writew(0, &hdr->flags)

Definition at line 206 of file xengrant.h.

◆ return

return

Definition at line 224 of file xengrant.h.